<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>Блог Костика &#187; English</title> <atom:link href="http://blog.kostik.net/category/english/feed/" rel="self" type="application/rss+xml" /><link>http://blog.kostik.net</link> <description>Они считают меня бандитом, издеваются над моим аппетитом</description> <lastBuildDate>Sun, 05 Feb 2012 06:07:21 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=</generator> <item><title>Kazakhstan businessman bought Sealand?</title><link>http://blog.kostik.net/2007/01/16/12/</link> <comments>http://blog.kostik.net/2007/01/16/12/#comments</comments> <pubDate>Tue, 16 Jan 2007 06:54:15 +0000</pubDate> <dc:creator>kostik</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[lytdybr]]></category><guid isPermaLink="false">http://blog.piterpen.net/2007/01/16/kazakstan-businessman-bought-sealand/</guid> <description><![CDATA[Kazakhstan&#8217;s site akipress.org informed, that Daniyar Ashimbaev (Данияр Ашимбаев) bought a SeaLand few days ago and is going to be a new SeaLand &#8220;king&#8221;. Akipress published a large interview (in Russian) with this person. He does not mention any reasons of this deal and does not say exactly how he will use the SeaLand, but&#8230;]]></description> <content:encoded><![CDATA[<p>Kazakhstan&#8217;s site <a href="http://kz.akipress.org" class="aga aga_3">akipress.org</a> informed, that Daniyar Ashimbaev (Данияр Ашимбаев) bought a <a href="http://www.sealandgov.org/" class="aga aga_4">SeaLand</a> few days ago and is going to be a new SeaLand &#8220;king&#8221;. Akipress published a<a href="http://kz.akipress.org/news/4354" class="aga aga_5"> large interview</a> (in Russian) with this person. He does not mention any reasons of this deal and does not say exactly how he will use the SeaLand, but promise, for example, to change SeaLand Dollar to SeaLand Tenge (Kazakhstan&#8217;s currency). I can not find any confirmations of this deal at other news sources, and I hope it is a fake.</p><p><strong>update: </strong>It was a fake of course. Never trust local news sites 8-).</p>]]></content:encoded> <wfw:commentRss>http://blog.kostik.net/2007/01/16/12/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Yet another faster JavaScript sorting</title><link>http://blog.kostik.net/2007/01/08/7/</link> <comments>http://blog.kostik.net/2007/01/08/7/#comments</comments> <pubDate>Mon, 08 Jan 2007 19:12:43 +0000</pubDate> <dc:creator>kostik</dc:creator> <category><![CDATA[AJAX]]></category> <category><![CDATA[English]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[работа]]></category><guid isPermaLink="false">http://blog.piterpen.net/2007/01/08/yet-another-faster-javascript-sorting/</guid> <description><![CDATA[It&#160;is&#160;no&#160;secret that the demand on&#160;applications with &#8220;AJAX&#8221; in&#160;the name is&#160;continually increasing. Nolens volens one has to&#160;do&#160;some things with unadapted to&#160;them tools: an&#160;illustration in&#160;point is&#160;Internet Explorer&#160;&#8212; a&#160;program which is&#160;unadapted to&#160;execution of&#160;the code that would be&#160;standardized and had a&#160;common sense. Recently I&#160;had to&#160;deal with one of&#160;its problems. I&#160;had to&#160;sort out an&#160;array of&#160;objects by&#160;the given field. IE&#160;did it&#160;100&#160;times&#8230;]]></description> <content:encoded><![CDATA[<p>It&nbsp;is&nbsp;no&nbsp;secret that the demand on&nbsp;applications with &ldquo;AJAX&rdquo; in&nbsp;the name is&nbsp;continually increasing. Nolens volens one has to&nbsp;do&nbsp;some things with unadapted to&nbsp;them tools: an&nbsp;illustration in&nbsp;point is&nbsp;Internet Explorer&nbsp;&mdash; a&nbsp;program which is&nbsp;unadapted to&nbsp;execution of&nbsp;the code that would be&nbsp;standardized and had a&nbsp;common sense. Recently I&nbsp;had to&nbsp;deal with one of&nbsp;its problems. I&nbsp;had to&nbsp;sort out an&nbsp;array of&nbsp;objects by&nbsp;the given field. IE&nbsp;did it&nbsp;100&nbsp;times slower than FireFox! Solution allows sorting out six times faster than Internet Explorer. A&nbsp;link to&nbsp;the library implementing this method follows. <span id="more-7"></span><h3>Problem</h3> With trivial code</p><p>// Array а&nbsp;contains 15000&nbsp;elements a.sort(function(a,&nbsp;b){return b.item&nbsp;&mdash; a.item;})</p><p>IE&nbsp;needs 40(!) seconds to&nbsp;think (15000&nbsp;was taken as&nbsp;a&nbsp;test, a&nbsp;real array is&nbsp;certainly less). (FireFox does the same in&nbsp;422ms, approximately 100&nbsp;times faster!) The realization of&nbsp;the sorting process on&nbsp;the server side would require changing of&nbsp;a&nbsp;large part of&nbsp;the code because the user selects a&nbsp;field and a&nbsp;method of&nbsp;sorting; this was a&nbsp;problem.<h3>Solution</h3> After short googling I&nbsp;found an&nbsp;<a href="http://www.lindsay.id.au/blog/?p=6" class="aga aga_9">excellent article by&nbsp;Russel Lindsay: &ldquo;Faster Javascript sorting&rdquo;</a>. He&nbsp;uses a&nbsp;simple trick: to&nbsp;rewrite the method toString() for addressing to&nbsp;the object&#8217;s property directly, convert numbers ([1, 2,&nbsp;10]&nbsp;into strings ['01','02','10']) and use sort() without parameters for increasing sorting speed. Below the results of&nbsp;the test (with my&nbsp;implementation of&nbsp;this idea):<pre>Internet Explorer41516ms – sort(function(a, b){return b.item - a.item;})</p>	
<p>7031ms - sort() for the array where numbers were converted into string</p>	
<p>7047ms – sort() and reverse() for the array where numbers were converted into stringFireFox</p>	
<p>438ms – sort(function(a, b){return b.item - a.item;})</p>	
<p>891ms - sort() for the array where numbers were converted into string</p>	
<p>954ms – sort() and reverse() for the array where numbers were converted into string</pre>Thus the trick of&nbsp;adding numbers with zeros to&nbsp;strings gives a&nbsp;six times quicker sorting in&nbsp;Internet Explorer and twice slower sorting in&nbsp;FF&nbsp;which allows using the code in&nbsp;both browsers.</p><p>Russel Lindsay uses the fixed size mask and the array ([1, 2,&nbsp;10]&nbsp;turns not into [01, 02,&nbsp;10]&nbsp;but into ['00000000001',' 00000000002',' 00000000010']). This is&nbsp;awful for many reasons and memory used is&nbsp;one of&nbsp;them. So&nbsp;I&nbsp;wrote a&nbsp;small library based on&nbsp;his code. It&nbsp;adds to&nbsp;Array() following methods: Array.sortIntAsc(property) and Array.sortIntDesc(property) for sorting array by&nbsp;integer property, Array.sortAsc(property), and Array.sortDesc(property) for sorting by&nbsp;string property.<h3>Example</h3> [js] var team = [ {name:&rsquo;Bill&rsquo;, age:25}, {name:&rsquo;John&rsquo;, age:21}, {name:&rsquo;Ann&rsquo;, age:20} ];</p><p>alert([team[0].name,team[1].name,team[2].name]); // Bill, John, Ann</p><p>team.sortIntAsc(&rsquo;age&rsquo;); alert([team[0].name,team[1].name,team[2].name]); // Ann, John, Bill</p><p>team.sortAsc(&rsquo;name&rsquo;); alert([team[0].name,team[1].name,team[2].name]); // Ann, Bill, John</p><p>[/js]<h3>My&nbsp;2&nbsp;cents</h3> This method is&nbsp;in&nbsp;my&nbsp;humble opinion a&nbsp;good solution of&nbsp;this particular problem (thank you, <a href="http://www.lindsay.id.au/blog/?p=6" class="aga aga_10">Russel</a>!). Also it&nbsp;is&nbsp;a&nbsp;good illustration: the best way to&nbsp;do&nbsp;something with data in&nbsp;the Internet Explorer is&nbsp;not to&nbsp;do&nbsp;anything. I&nbsp;mean to&nbsp;organize the data processing flow in&nbsp;such a&nbsp;way as&nbsp;to&nbsp;leave the data processing (including any sorting) on&nbsp;the server side. Otherwise when IE&nbsp;will deal with trivial tasks terrible you will have to&nbsp;spend a&nbsp;lot of&nbsp;time to&nbsp;find a&nbsp;strange detour.</p><p><a href="http://blog.piterpen.net/wp-content/uploads/2007/01/arraysort.zip" class="aga aga_11"> download library (zip)</a></p>]]></content:encoded> <wfw:commentRss>http://blog.kostik.net/2007/01/08/7/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using apc
Page Caching using apc
Database Caching 8/23 queries in 0.008 seconds using apc
Object Caching 383/536 objects using apc

Served from: blog.piterpen.net @ 2012-02-06 01:41:12 -->
