better gyp
ä»äºã§ãããã gyp ã使ã£ã¦æ©ããï¼å¹´ã«ãªããããã¤ãå人çã«çãã¨ãããä¿®æ£ãã¦å
¬éãã¦ã¿ãã
- Github ã«ããã¦ããä¿®æ£ç
- ãªãªã¸ãã«
ä¿®æ£ã¯ä»¥ä¸ã®ã¨ããã
- Android: é cygwin ã§ããã«ãã§ããããã«ãã
- Android: *.so ããã«ãããã¨ãã® name mangling è¦åãç·©ããããããã«ãã
- Windows: MIDL ãªãã·ã§ã³ã® ValidateParametersãGenerateTypeLibrary ããµãã¼ããã
ãããè¦ã¦ã¡ããã¨ããã°æ¬æµã«åãè¾¼ãã§ããããããªï¼
faster octree color quantization
256è²ç»åå ¨çæã¯ã¨ã£ãã«éãå»ã£ãæãããã¾ãããä»åã¯ç»åã256è²ä»¥ä¸ã«æ¸è²ããã¨ãã話ã§ããæ¸è²ãããç»åã®ç»è³ªãåä¸ãããæ¹æ³ã¨ãã¦èª¤å·®æ¡æ£æ³ãããã¾ãããä»åã¯ããã¯ããã¾ããã
æ¸è²ããæ¹æ³ã¯å¤§æããç 究ããã¦ãã¦æåãªãã®ãããã¤ãããã¾ãã
- åçéååæ³ (uniform quantization)
- RGB888ãªã©ãRGB332ãªã©ã«ãããã³ã°ãã
- é«éãåç´ãç°¡æãã ãç»è³ªã¯ä½ã
- é »åº¦æ³ (popularity algorithm)
- ç»ç´ ã®åºç¾é »åº¦ãããã¬ãããä½æãã
- ç»è³ªã¯ãã¾ãã¡
- ä¸å¤®å¤åå²æ³ (median cut algorithm)
- ä¸æã¯æå¼·ã¨å¼ã°ãã¦ããææ³
- è²ç©ºéãäºåãã¦ãã
- è¤éã ãå²ã¨é«éã§å²ã¨ããã
- è²ç©ºéã¯RGBãããYCbCrã§åå²ããæ¹ãããã¯ã
- å
«åæ¨ (octree algorithm)
- ç¾å¨æå¼·ã®ææ³
- ã¢ãã³ã§ç°¡æ½ã§é«éã§ããã
- 以ä¸ã®ææ¸ã¨ã½ã¼ã¹ã³ã¼ããåããããã
ä»åã¯octreeãããã¾ããç»è³ªã追æ±ããã®ã¯Image Magickãªã©ããã£ã¦ãã¾ãã®ã§ãé度ã追æ±ãã¦ã¿ã¾ããããoctreeã®è¨ç®éã¯ãç»åã®æ¨ªå¹
ãWã縦å¹
ãHãæ·±ããDã¨ããã¨ãO(W*H*D)ã¨ãªãã¾ãã試ããéãã ã¨ãoctreeã ã¨æ·±ãã4ã5ç¨åº¦ã§ç»åã人ãèªèããã«ã¯ååãªç»è³ªãå¾ããã¾ããããããããã«ã¼ãåæ°ãå¤ããã¾ãããã¯ã»ã«å¦çãªã®ã«ãã¯ã»ã«å¦çãã¦ãã¿ãããªè¨ç®éã§ãã
éååã«ã¼ãã®æé©åãã®ï¼
octreeã®ã«ã¼ãå¦çã®ã³ã¼ããè¦ãã¨ãåãç»ç´ ã«å¯¾ãã¦ã¯å ¨ãåãå¦çãç¹°ãè¿ãããã¨ãããã¨ãåããã¾ãããããå©ç¨ããæé©åãèãã¾ããç»åã®ãã¹ãã°ã©ã ãæ±ãããã¨ãã§ããã°ãç»åã®è²æ°åã ãã®ã«ã¼ãã§æ¸ã¿ããã§ãããç»åã®è²æ°Cã¯ãå¿ ãC<=W*H以ä¸ã«ãªãã®ã§ãè¨ç®éã¯å¿ ãæé©ååãããå°ãããªãã¾ãã
ç»åã®è²æ°åã ãã«ã¼ãããæ¹æ³ã«å¦çãæ¸ãæããã«ã¯ãç»åã®ãã¹ãã°ã©ã ãæ±ããå¿ è¦ãããã¾ããç»åã®ç»ç´ ãã½ã¼ããããã¨ã§ç»åã®ãã¹ãã°ã©ã ãæ±ãããã¨ãã§ãã¾ãã*1ãã½ã¼ãã¯å²ã¨ã³ã¹ãããããã®ã§é«éåã«ã¯ä½¿ãã¾ãã*2ããã£ã¦ãçé¢ç®ã«ãã¹ãã°ã©ã ãè¨ç®ããæ¹ãè¯ãããã§ããããããçé¢ç®ã«ãã¹ãã°ã©ã ãè¨ç®ããã¨å¤§éã«ã¡ã¢ãªãå¿ è¦ã«ãªãã¾ããRGB888ã§ããã¹ãã°ã©ã ã®åè¦ç´ ã符åãªãæ´æ°ã§ç®¡çããã¨ã2^24*4ã§64MBãã®ã¡ã¢ãªãå¿ è¦ã«ãªã£ã¦ãã¾ãã¾ããæè¿ã®ç«¯æ«ããµã¼ããªãä½è£ãªæ°ããã¾ãããé·ããã¨ã¯ã©ã¤ã¢ã³ãã¢ããªãä½ã£ã¦ããç§ã®æè¦çã«ã¯ã¡ã¢ãªã使ãéãã§ãããè²æ°ã1677ä¸è²ãããã¨ææªã§65536x65536ã®ç»åã«ç¸å½ããå¦çããããªãã¨ãããªããªãã®ã§é«éåã§ããã®ããä¸å®ã«ãªã£ã¦ãã¾ããã¨ããããã§ã精度ãè½ã¨ããã¨ãèãã¦ã¿ã¾ãããã
- RGB888 -> 2^24*4 -> 64MB (65536x65536ç¨åº¦ã®ç»åã«ç¸å½ãã)
- RGB777 -> 2^21*4 -> 8MB (2896x2896ç¨åº¦ã®ç»åã«ç¸å½ãã)
- RGB666 -> 2^18*4 -> 1MB (1024x1024ç¨åº¦ã®ç»åã«ç¸å½ãã)
- RGB565 -> 2^16*4 -> 256KB (512x512ç¨åº¦ã®ç»åã«ç¸å½ãã)
- RGB555 -> 2^15*4 -> 128KB (362x362ç¨åº¦ã®ç»åã«ç¸å½ãã)
- RGB444 -> 2^12*4 -> 16KB (128x128ç¨åº¦ã®ç»åã«ç¸å½ãã)
æè¦çã«RGB666ç¨åº¦ãªã精度çã«ãé度çã«ã空éçã«ãããããã§ãããå®éã«è©¦ãã¦ã¿ãã¨ãããæå
ã®ãã·ã³ã§å¦çæéã30ã50ããªç§ç¨åº¦ãã10ããªç§ä»¥ä¸ã¾ã§åæ¸ã§ãã¾ãããããã§ãããããããé«éååã¨çµæãç°ãªãã¾ããé«éååã®æ¹ãç»è³ªãããã§ããããã¯é«éå+RGB888ã§ãã£ã¦ãé«éååã®ç»è³ªã«å£ãã¾ãã»ã»ã»ããã£ããã®octreeãå°ç¡ãã§æ®å¿µã§ããã
éååã«ã¼ãã®æé©åãã®ï¼
ãã¼ããã£ãã·ã¥
octreeã¯åçã«å «åæ¨ã®ãã¼ãã«ä½¿ãã¡ã¢ãªã確ä¿ã»ç ´æ£ãã¾ãã確ãã«ç©ºéçãªå¹çã¯ããã§ããåçºå¼ã³åºããªãããã ããç¹°è¿ãå¼ã³åºãã¨ã¡ã¢ãªã®æçåãèµ·ãã£ã¦OSã«ãã¾ãåªãããªãæ°ããã¾ããåªãããªãã®ã¯ç´³å£«çã§ã¯ããã¾ããã®ã§ãåªããã§ããªãããèãã¦ã¿ã¾ããããå°ããã¡ã¢ãªã®ç¢ºä¿ã»ç ´æ£ãé£ç¶ããã¨æçåãçºçããããã§ããã確ä¿ã»ç ´æ£ããªããã°æçåã¯çºçãã¾ããããã¼ãããã¼ã«ãã¦ããã°ããããã§ãããã§ã¯ããã¤ãã¼ã«ãã¦ããã°ããã§ããããï¼ããã¯å «åæ¨ã®æ·±ãã«ããã¾ããããããã®æ·±ãã®ãã¼ããããã¤åå¨ãããããèãã¦ã¿ã¾ãããã
- æ·±ã 0 -> ãã¼ãæ° 1
- æ·±ã 1 -> ãã¼ãæ° 8
- æ·±ã 2 -> ãã¼ãæ° 64
- æ·±ã 3 -> ãã¼ãæ° 512
- æ·±ã 4 -> ãã¼ãæ° 4096 (4K)
- æ·±ã 5 -> ãã¼ãæ° 32768 (32K)
- æ·±ã 6 -> ãã¼ãæ° 262144 (256K)
- æ·±ã 7 -> ãã¼ãæ° 2097152 (2MB)
- æ·±ã 8 -> ãã¼ãæ° 16777216 (16MB)
ä¸ã§æ·±ã4ã5ã§ååãªç»è³ªãå¾ãããã¨æ¸ããã®ã§ãæ·±ã4ã¾ã§ãã£ãã·ã¥ãããã¨ãèãã¦ã¿ã¾ããããæ·±ã4ã¾ã§ã®ãã¼ããé£ç¶ããã¢ãã¬ã¹ç©ºéã«é
ç½®ããããã«ãé åºä»ããèãã¦ã¿ã¾ããããä¾ãã°ãããªæãã§ãã
- æ·±ã 0 -> 0
- æ·±ã 1 -> 1ã8 (1+n)
- æ·±ã 2 -> 9ã72 (1+(1+n)*8 = 1+8+8*n)
- æ·±ã 3 -> 73ã584 (1+8+(1+n)*64 = 1+8+64+64*n)
- æ·±ã 4 -> 585ã4680 (1+8+64+(1+n)*512 = 1+8+64+512+512*n)
ããã§æ·±ãã«å¿ããé åºä»ããã§ãã¾ãããç°¡åã§ããã
ãã¬ããã¤ã³ãã¯ã¹ä»ã®æé©å
ä¸è¨ã®å¦çã§é«éã«ãã¬ãããçæã§ããããã«ãªãã¾ããããå®éã«æ¸è²ãããç»åãå¾ãã«ã¯çæãããã¬ããã¨ç»åã対å¿ä»ããå¿ è¦ãããã¾ãããã®ç»ç´ ã¯ãã¬ããã§ããã¨ã©ã®è²ã ãã¨ããå¦çã§ãããoctreeã¯å ¨ã¦ã®ç»ç´ ãå¦çããã¾ã§ãã¬ããã決å®ãããªãã®ã§ãå¹ççãªéå¼ããé£ããã®ã§ããä½ã®åææ¡ä»¶ããªãå ´åãè¿ä¼¼è²è¨ç®ã¯ç»ç´ æ¯ã«ãã¬ããã®å ¨ã¨ã³ããªã¨ã®è²ç©ºéã®è·é¢ã調ã¹ã¦æãè·é¢ãå°ãããã®ãé¸æãã¦ããã¨ããå¦çã«ãªãã¾ããè¨ç®éã¯ãã¬ããã®ã¨ã³ããªæ°ãPã¨ããã¨O(W*H*P)ã¨ãªãã¾ããã¾ããã¯ã»ã«å¦çã¿ããã«ãªã£ã¦ã¾ãããã¯ã»ã«å¦çã¯ç¦æ¢ã§ããæè¦çã«ã¯ãç»ç´ ããããã·ã¥çã«ãã¬ããã®ã¤ã³ãã¯ã¹ãæ±ãããã¨ãã§ããã°é«éã«å¦çã§ããããªæ°ããã¾ãã
*1:http://d.hatena.ne.jp/izariuo440/20120320/1332212854
*2:ç§ã試ããéãã§ã¯ãã½ã¼ãã ãã§æé©ååã®octreeã®å¦çãããæéãããã£ã¦ãã¾ãã¾ããããç»ç´ æ°ã«ãã£ã¦ã¯ã½ã¼ãã®æ¹ãéãããããã¾ãã
gyp ã§ãã¤ãã£ãã³ã¼ãããã¸ã§ã¯ãã®ãã«ããå¤ç°å¢ã«å¯¾å¿ããã
ä»åã¯ãgyp ã§ãã¤ãã£ãã³ã¼ãããã¸ã§ã¯ãã®ãã«ããå¤ç°å¢ã«å¯¾å¿ããããã§ããç§ããã£ã¦ãããã¨ãã¡ã¢ãã¦ããã¾ãã
èæ¯
ç§ã¯ Windows ã®ã³ã¼ããããæ¸ãã¦ãã¾ãããããæãã AndroidãWindows MobileãLinuxãMac OS XãiOS ã§ãåãããã«æèãã¦æ¸ãããã«ãªãã¾ãããããã«ãã³ã¼ãããã«ãããããã®å種è¨å®ãã¡ã¤ã«ãç¨æããã®ãé¢åã«ãªãã¾ãããVisual StudioãXcodeãMakefileãAndroid NDK ç¨ Makefileã»ã»ã»ãã£ã¦ãããã¾ãããã
ãã«ããã¼ã«å·¡ãã»ã»ã»cmakeãsconsãwafããã㦠gyp ã¸
ãã«ãè¨å®ãã¡ã¤ã«ãèªåçæããããã®ãã«ããã¼ã«ãæ¢ãã¦ã¿ãã¨ããã«ããã¤ãåºã¦ãã¾ãããåå¹´ã»ã© cmake 㨠scons ã並è¡éç¨ãã¦ãã¾ãããããã®ä¸ã§æ°ã«å ¥ããªãç¹ãåºã¦ãã¾ããã
- ãã«ãã¯ã§ããã Visual StudioãXcode ãªã©ã®ããã¸ã§ã¯ããã¡ã¤ã«ãçæã§ããªã
- sconsãwaf ãªã©ã¯ãã
- Visual StudioãXcode ã®ããã¸ã§ã¯ããã¡ã¤ã«ãçæã§ãããä¸èº«ãã¤ãã¤ã
- cmake ã§ã¯ãinclude ãã£ã¬ã¯ããªããªãã絶対ãã¹ã ã£ãããã
- ããã¸ã§ã¯ãéã®è¨å®ã®å
±æãã¤ãã¤ã
- Android NDK ã® export ã®æ¦å¿µã«ç¸å½ãããã®ããã£ãããªãã£ãã
- Android NDK ã«å¯¾å¿ãã¦ããªã
- å½æ㯠cmakeãsconsãwaf ã©ãã対å¿ãã¦ã¾ããã§ãã
ãã®è¾ºããã¹ã¦ãã¾ã対å¿ãã¦ãããã®ããgyp*1 ã§ããgyp 㯠Google Chrome ãã¯ããã¨ãã Google 製ã¯ã©ã¤ã¢ã³ãããã°ã©ã ãä¸å¿ã«å©ç¨å®ç¸¾ãããã¾ã*2ãGoogle æ¥æ¬èªå
¥åã®ãã¼ã¹ã§ãã mozc ãªãããããã§ãããnode.js*3ããã®ä¸ã§åãã¦ãã v8*4ãlibuv ãªããã gyp ã§ãã«ããããããã«ãªã£ã¦ãã¾ãããã ããgyp ã®ã¹ã¯ãªããã¯Python 2.4 ã ã¨åããªã*5ã®ã§ãCent OS ãªã© Python 2.4 ãæ¢å®ã®ç°å¢ã§ã¯å°å³ã«è¾ãã®ã§ãããæã§ãã«ãè¨å®ãã¡ã¤ã«ãæ¸ããã¨ã«æ¯ã¹ãã°ããããªåé¡ã§ãã
gyp ãããã¸ã§ã¯ãã«é ç½®ãã
gyp ã¯ãã ã® Python ã¹ã¯ãªãã群ã§ããNew BSD ã©ã¤ã»ã³ã¹ãªã®ã§ãèªåã®ããã¸ã§ã¯ãã«çµã¿è¾¼ãã§ãã¾ãã®ã楽ããããã¾ãããç§ã®å ´åã¯ãnode.js ãåèã«ä»¥ä¸ã®ããã«ãã¦éç¨ãã¦ãã¾ãã
- $PROJECT_ROOT/tools/gyp
- gyp ä¸å¼ãé ç½®ãã
- $PROJECT_ROOT/build/common.gypi
- åããã¸ã§ã¯ãã®å
±éè¨å®ãæ¸ã
- Visual Studio ã®ããã¸ã§ã¯ãè¨å®ãXcode ã®ããã¸ã§ã¯ãè¨å®ãªã©
- åããã¸ã§ã¯ãã®å
±éè¨å®ãæ¸ã
- $PROJECT_ROOT/configure.py
- gyp ãå¼ã³åºãã¦ããã¸ã§ã¯ããã¡ã¤ã«ãçæããã¹ã¯ãªãããæ¸ã
- $PROJECT_ROOT/README.md
- ãã«ãæé ãæ¸ã
Android NDK åãã®ãã³å ¥ã
gyp ãçæãã Android NDK ç¨ã® Makefile ã§ãã«ãããã¨ããããã¨é·ããã¡ã¤ã«åã«ãªã£ã¦ãã¾ãã®ã§ãç§ã¯ä»¥ä¸ã®ãã¡ã¤ã«ãä¸é¨ä¿®æ£ãã¦ãã¡ã¤ã«åãçããªãããã«ãã¦ãã¾ãã
- $PROJECT_ROOT/tools/gyp/pylib/gyp/generator/android.py
- ComputeAndroidModule 㧠return self.target ããããã«ãã¦ãã
ã¾ã¨ã
ãã®è¨äºã«ã¯å ·ä½ä¾ãããã¾ããããGithub ã® node.js ã®ã³ã¼ããä½ãããéå¼ã§ãã
*1:https://code.google.com/p/gyp/
*2:gyp 㯠Google Chrome ãªã©ãä»ç°å¢ã§ãã«ãããããã®ä½ããããã®ã§ã以å㯠scons ã§ãã«ãããã¦ãã¾ãã
*3:以å㯠waf ã§ãã«ãããã¦ãã¾ãã
*4:以å㯠scons ã§ãã«ãããã¦ãã¾ãã
*5:with ãªã©æ°ããæ§æã使ã£ã¦ãããã
tiny hash table
Cã§ã³ã¼ããæ¸ãã¦ããã¨ããã·ã¥ãã¼ãã«*1ã欲ãããªããã¨ãå¤ã ããã¾ããã¨ããããã§å°ããã®ãæ¸ãã¦ã¿ã¾ããã
ããã·ã¥ãã¼ãã«ã«ã¤ãã¦
ããã·ã¥ãã¼ãã«ã¯ããããã¼ãããã·ã¥é¢æ°ã使ã£ã¦ãããã³ã°ããããã«å¯¾å¿ããå¤ãé¢é£ä»ããããã®ãã¼ã¿æ§é ã§ããé£æ³é åã¨ãã¦ä½¿ãããããããã·ã¥ãããã¨å¼ã°ãããããã¾ããããã·ã¥é¢æ°ã«ãã£ã¦ãã¼ãã¤ã³ããã¯ã¹ã«å¤æãï¼ãããããã·ã¥ã¨å¼ã¶ï¼ãããã«å¯¾å¿ããé åã®è¦ç´ ï¼ã¹ãããã¾ãã¯ãã±ãã¨å¼ã°ããï¼ã«å¤ãå ¥ãã¦ããã¾ããããããã¡ã¢ãªã使ãã¾ããããã®åé«éã«åä½ãã¾ãã
æ¢ç´¢ã«ããã¦ãæ¨æ§é ãªã©ã®äºåæ¢ç´¢ããã¼ã¹ã¨ããå®è£
ã§ã¯ããã¼ã®æ¯è¼åæ°ãlog2(N)ã¨ãªãã¾ãããããã·ã¥ãã¼ãã«ã§ã¯å¤§æµãããããå°ãããªãã¾ããæ¯è¼åæ°ããããããå¤ããªããããªç¶æ³ãã¤ã¾ãè¡çªãå¤çºããç¶æ³ã§ã¯ãè¡çªãå¤çºããªããããªããã·ã¥é¢æ°ãé¸æãããããã±ãã大ããããããæ¨æ§é ãªã©äºåæ¢ç´¢ããã¼ã¹ã¨ããå®è£
ãç¨ãããªã©ã®åé¿çãããã¾ããã»ã¼Wikipediaãªå
容ã§ãã¿ã¾ããã
thtblã®ç¹å¾´
- ããã·ã¥é¢æ°ã¯èªåã§ç¨æãã
- ãã¼ããªã¥ã¼ã¯åããã«èªåã§ç®¡çãã
- å é¨ã«ã³ãã¼ãæããã«ãã¤ã³ã¿ã«ããåç §ã®ã¿è¡ã
- ç·å½¢æ¢æ»å(linear-probing)ã®ãªã¼ãã³ã¢ãã¬ã¹æ³(open-addressing)ã«ããè¡çªåé¿ãè¡ã
- å¤åç°å¢ä¾åããªã
- ãã±ãã溢ãããã§ãèªå伸é·ããªã
- ãã±ãã®ãµã¤ãºã¯ç´ æ°ã§ã¯ãªã2ã®Nä¹
- å·¡åãåè¦ç´ åé¤ãé ã
工夫ããã¨ãã
ãªã¼ãã³ã¢ãã¬ã¹æ³ã ã¨ããã¤ã³ã¿ã®ç®¡çã¨ã¯å¥ã«ããã®å¤ãã空ããåé¤æ¸ã¿ãã使ç¨ä¸ããåºå¥ããå¿ è¦ãããã¾ãããã¤ã³ã¿ã¨ä»ã«ãã¼ãã³ã°ç¨ã®ãã¼ã¿ãç¨æããã®ã¯é¢åã ãã¡ã¢ãªã使ãããã§å«ã ã£ãã®ã§ããã¤ã³ã¿ã®ã¢ãã¬ãã·ã³ã°ã®ä»çµã¿ãå©ç¨ãã¦ãã¤ã³ã¿ã®ã¿ã§ç®¡çãããã¨ã«ãã¾ããã大æµã®OSã§ã¯ãã«ã¼ãã«ã©ã³ãã¨ã¦ã¼ã¶ã©ã³ãã§ããããã¢ãã¬ã¹ç©ºéãåããã¦ãã¾ãã以ä¸ã®ãã¼ã¸ãè¦ãã¨ã大æµã®OSã§ã¯ã«ã¼ãã«ã©ã³ãã大ããçªå°ãå ãã¦ãããã¨ãåããã¾ãã
- http://www.alde.co.jp/information/linux/memoryoflinux.html
- http://technet.microsoft.com/ja-jp/windows/ee424286
ã¨ããããã§ã以ä¸ã®ããã«åºå¥ãããã¨ã«ãã¾ãããç§ã¯ã«ã¼ãã«ã©ã³ãã§åä½ãããã®ã¯æ¸ããªãã®ã§ã
- 空 â NULL
- åé¤æ¸ã¿ â 0xffffffff ã¾ã㯠0xffffffffffffffffLLU
- 使ç¨ä¸ â ä¸è¨ä»¥å¤
GNU hashtabã¨ããããã·ã¥ãã¼ãã«ã©ã¤ãã©ãªãä¼¼ããããªãã¨ããã¦ãã¦ãmallocãªã©ã¯1ãè¿ããªãã¨ããåæã®å
ã«å®è£
ããã¦ãã¾ããå°ããçªå°ã¯å¤§æµä½ããã®ã¢ããªã®ã¹ã¿ãã¯ã使ã£ã¦ããã®ã§ã確ãã«ãã®åæã¯ããã¦ãæç«ãããã§ããããã
å®è¡çµæ
ããã¤ãã®ããã·ã¥é¢æ°ãããã¤ãã®ãã±ãã®å¤§ããã§è¡çªããã¾ããã§æ¿å ¥ã ããã³ããã¼ã¯ãã¨ã£ã¦ã¿ã¾ãããè¡çªçã®ä½ãã ããæ§è½ã®æ±ºå®çè¦ç´ ã§ã¯ãªããæ¯è¼é¢æ°ã®ã³ã¹ããéè¦ãªè¦ç´ ã ããã¨ãããã¨ãããåããçµæã«ãªã£ã¦ãã¾ããã
128
string
searches: 128, collisions: 204 (1.593750%)
0.000243 [sec]
zackw
searches: 128, collisions: 416 (3.250000%)
0.000212 [sec]
FNV-1a
searches: 128, collisions: 51 (0.398438%)
0.000214 [sec]1024
string
searches: 1024, collisions: 5048 (4.929688%)
0.001869 [sec]
zackw
searches: 1024, collisions: 1920 (1.875000%)
0.001591 [sec]
FNV-1a
searches: 1024, collisions: 503 (0.491211%)
0.001523 [sec]8192
string
searches: 8192, collisions: 43510 (5.311279%)
0.013948 [sec]
zackw
searches: 8192, collisions: 51554 (6.293213%)
0.012849 [sec]
FNV-1a
searches: 8192, collisions: 3827 (0.467163%)
0.011939 [sec]16384
string
searches: 16384, collisions: 849376 (51.841797%)
0.042020 [sec]
zackw
searches: 16384, collisions: 38040 (2.321777%)
0.024676 [sec]
FNV-1a
searches: 16384, collisions: 6266 (0.382446%)
0.024592 [sec]32768
string
searches: 32768, collisions: 1692528 (51.651855%)
0.083191 [sec]
zackw
searches: 32768, collisions: 23370 (0.713196%)
0.047768 [sec]
FNV-1a
searches: 32768, collisions: 17951 (0.547821%)
0.049201 [sec]65536
string
searches: 65536, collisions: 2047008 (31.234863%)
0.141463 [sec]
zackw
searches: 65536, collisions: 121870 (1.859589%)
0.098748 [sec]
FNV-1a
searches: 65536, collisions: 45944 (0.701050%)
0.100855 [sec]1048576
string
searches: 1048576, collisions: 30468520 (29.057045%)
2.362834 [sec]
zackw
searches: 1048576, collisions: 3814406 (3.637701%)
1.755987 [sec]
FNV-1a
searches: 1048576, collisions: 515284 (0.491413%)
1.933815 [sec]
ãã®ä»
å®è£ ã«ãããåèã«ãããã¼ã¸ãªã©ã
- http://preshing.com/20110603/hash-table-performance-tests
- http://isthe.com/chongo/tech/comp/fnv/
- http://code.google.com/p/smhasher/
- http://www.nurs.or.jp/~sug/soft/super/hash.htm
- http://www.atmarkit.co.jp/news/analysis/200803/24/semi.html
- http://gcc.gnu.org/svn/gcc/trunk/include/hashtab.h
- http://gcc.gnu.org/svn/gcc/trunk/libiberty/hashtab.c
ç»åã®è²æ°ãæ±ããããã¹ãã°ã©ã ãä½ãããã®ã½ã¼ããããããå®è£ ãã¦ã¿ã
ç»åã®è²æ°ãæ±ããã«ã¯ããã·ã¥çãªãã®ã使ããããã½ã¼ãããæ¹ãéãã¨ãã話ã§ãã
- http://blog.livedoor.jp/junki560/archives/21233822.html
- http://blog.livedoor.jp/junki560/archives/21305807.html
ã¾ãããã¹ãã°ã©ã ãé«éã«ä½ããã¨ããã¨è²ã®æ·±åº¦ã«å¿ãã¦ã¡ã¢ãªãé£ãã¾ããRGBããããã8ãããã ã¨64MBã»ã©ã¡ã¢ãªãé£ãã¾ãã対ãã¦ã½ã¼ãã§ãããã¨ããã¨ãç»ç´ æ°åã ãã§æ¸ãã®ã§ã¡ã¢ãªçã«ãåªããã§ãã
ãããªããã§ãã½ã¼ãã§ããä¸è¨ã§ã¯ã¯ã¤ãã¯ã½ã¼ãã使ã£ã¦ã¾ãããã¯ã¤ãã¯ã½ã¼ããæåæã¨ã¯éãã¾ãããæè¿ã¯ã¡ã¢ãªãè±å¯ãªã®ã§ããã±ãã½ã¼ããåå¸æ°ãä¸ãã½ã¼ããåºæ°ã½ã¼ããååå®ç¨çã§ããã©ããããã ãããã¨ããããã§ããã¤ã試ãã¦ã¿ã¾ãããã¯ã¤ãã¯ã½ã¼ããåå¸æ°ãä¸ãã½ã¼ããåºæ°ã½ã¼ããææã¡ã®Mac Book Airã§è©¦ãã¦ã¿ã¾ãããã³ã¼ãã¯ãã¡ãã
4ãã¤ãã®ç¬¦åãªãæ´æ°ãã½ã¼ãããã¨ããç°¡åãªã³ã¼ãã§ãã以ä¸ã®ã½ã¼ããæ¯ã¹ã¦ãã¾ãã
- æ¨æºCã©ã¤ãã©ãªã®ã¯ã¤ãã¯ã½ã¼ã
- ææ¸ãã®ã¯ã¤ãã¯ã½ã¼ã
- åå¸æ°ãä¸ãã½ã¼ãï¼æå¾ã®ã³ãã¼å¦çãmemcpyï¼
- åå¸æ°ãä¸ãã½ã¼ãï¼æå¾ã®ã³ãã¼å¦çãforã«ã¼ãï¼
- åå¸æ°ãä¸ãã½ã¼ãï¼æå¾ã®ã³ãã¼å¦çãmemcpyããã¤ã³ã¿ã使ã£ã¦ã«ã¼ããå°ãæé©åï¼
- åºæ°ã½ã¼ãï¼ãã¤ãåä½ï¼
- åºæ°ã½ã¼ãï¼ãã¤ãåä½ããã¤ã³ã¿ã使ã£ã¦ã«ã¼ããå°ãæé©åï¼
- åºæ°ã½ã¼ãï¼ãã¤ãåä½ããã¤ã³ã¿ã使ã£ã¦ã«ã¼ããããã«æé©åï¼
- åºæ°ã½ã¼ãï¼ã¯ã¼ãåä½ï¼
çµæã¨ãã¦ã¯ãæ¦ãã¯ã¼ãåä½ã®åºæ°ã½ã¼ããæãéãã£ãã§ããã¤ãããã§ãç»åå¦çã§ã¯ã¯ã¼ãåä½ã®åºæ°ã½ã¼ãã使ãã®ãããããã§ããåºæ°ã½ã¼ãã¯å°ãã ã工夫ãã¾ãããåºæ°ã½ã¼ãã§ã¯ãæ®éã¯åä½æ¯ã«çµæãã³ãã¼ããã®ã§ãããããã«ãããã¡ãªã³ã°ãããã¨ã§ãã®æéããªããã¾ãããç»ç´ æ°ã大ãããªãã°ãªãã»ã©å¹ãã¦ããã¯ãã§ãã以ä¸ã¯ãMac Book Air 2.13 GHz Intel Core 2 Duo, Memory 4 GB 1067 MHz DDR3ã§å®è¡ããçµæã§ããã¾ãã¯å®æ©ã§ã®çµæã
QVGA 24bpp 320x 240 (size = 76800, range = 16777216)
qsort : 0.023937 [sec]
quick_sort : 0.022483 [sec]
counting_sort : 0.211722 [sec]
counting_sort2 : 0.146360 [sec]
counting_sort3 : 0.133482 [sec]
radix_sort : 0.006259 [sec]
radix_sort2 : 0.005574 [sec]
radix_sort3 : 0.005545 [sec]
radix_sort4 : 0.004007 [sec]VGA 24bpp 640x 480 (size = 307200, range = 16777216)
qsort : 0.105436 [sec]
quick_sort : 0.092361 [sec]
counting_sort : 0.184831 [sec]
counting_sort2 : 0.184686 [sec]
counting_sort3 : 0.169230 [sec]
radix_sort : 0.025758 [sec]
radix_sort2 : 0.024495 [sec]
radix_sort3 : 0.023203 [sec]
radix_sort4 : 0.015684 [sec]XGA 24bpp 1024x 768 (size = 786432, range = 16777216)
qsort : 0.288884 [sec]
quick_sort : 0.260471 [sec]
counting_sort : 0.274694 [sec]
counting_sort2 : 0.272200 [sec]
counting_sort3 : 0.257774 [sec]
radix_sort : 0.069239 [sec]
radix_sort2 : 0.066146 [sec]
radix_sort3 : 0.060907 [sec]
radix_sort4 : 0.040482 [sec]Nexus S 24bpp 480x 800 (size = 384000, range = 16777216)
qsort : 0.134426 [sec]
quick_sort : 0.118140 [sec]
counting_sort : 0.198503 [sec]
counting_sort2 : 0.198470 [sec]
counting_sort3 : 0.182864 [sec]
radix_sort : 0.033405 [sec]
radix_sort2 : 0.031146 [sec]
radix_sort3 : 0.029891 [sec]
radix_sort4 : 0.019964 [sec]Mac Book Air 24bpp 1440x 900 (size = 1296000, range = 16777216)
qsort : 0.492288 [sec]
quick_sort : 0.439028 [sec]
counting_sort : 0.376246 [sec]
counting_sort2 : 0.370595 [sec]
counting_sort3 : 0.353696 [sec]
radix_sort : 0.113894 [sec]
radix_sort2 : 0.110131 [sec]
radix_sort3 : 0.102530 [sec]
radix_sort4 : 0.069099 [sec]iMac 24bpp 2560x1440 (size = 3686400, range = 16777216)
qsort : 1.493648 [sec]
quick_sort : 1.320081 [sec]
counting_sort : 0.833016 [sec]
counting_sort2 : 0.819314 [sec]
counting_sort3 : 0.810189 [sec]
radix_sort : 0.332729 [sec]
radix_sort2 : 0.316817 [sec]
radix_sort3 : 0.292213 [sec]
radix_sort4 : 0.200232 [sec]
åããã·ã³ã§Windows XP on Virtual Boxã§å®è¡ããçµæããã¡ãã
QVGA 24bpp 320x 240 (size = 76800, range = 16777216)
qsort : 0.016000 [sec]
quick_sort : 0.000000 [sec]
counting_sort : 0.485000 [sec]
counting_sort2 : 0.765000 [sec]
counting_sort3 : 0.719000 [sec]
radix_sort : 0.000000 [sec]
radix_sort2 : 0.031000 [sec]
radix_sort3 : 0.000000 [sec]
radix_sort4 : 0.016000 [sec]VGA 24bpp 640x 480 (size = 307200, range = 16777216)
qsort : 0.093000 [sec]
quick_sort : 0.047000 [sec]
counting_sort : 0.687000 [sec]
counting_sort2 : 0.844000 [sec]
counting_sort3 : 0.828000 [sec]
radix_sort : 0.062000 [sec]
radix_sort2 : 0.047000 [sec]
radix_sort3 : 0.047000 [sec]
radix_sort4 : 0.047000 [sec]XGA 24bpp 1024x 768 (size = 786432, range = 16777216)
qsort : 0.234000 [sec]
quick_sort : 0.188000 [sec]
counting_sort : 0.656000 [sec]
counting_sort2 : 0.781000 [sec]
counting_sort3 : 0.812000 [sec]
radix_sort : 0.188000 [sec]
radix_sort2 : 0.235000 [sec]
radix_sort3 : 0.171000 [sec]
radix_sort4 : 0.109000 [sec]Nexus S 24bpp 480x 800 (size = 384000, range = 16777216)
qsort : 0.125000 [sec]
quick_sort : 0.063000 [sec]
counting_sort : 0.625000 [sec]
counting_sort2 : 0.719000 [sec]
counting_sort3 : 0.813000 [sec]
radix_sort : 0.047000 [sec]
radix_sort2 : 0.046000 [sec]
radix_sort3 : 0.047000 [sec]
radix_sort4 : 0.047000 [sec]Mac Book Air 24bpp 1440x 900 (size = 1296000, range = 16777216)
qsort : 0.359000 [sec]
quick_sort : 0.282000 [sec]
counting_sort : 0.563000 [sec]
counting_sort2 : 0.906000 [sec]
counting_sort3 : 0.969000 [sec]
radix_sort : 0.297000 [sec]
radix_sort2 : 0.281000 [sec]
radix_sort3 : 0.250000 [sec]
radix_sort4 : 0.156000 [sec]iMac 24bpp 2560x1440 (size = 3686400, range = 16777216)
qsort : 0.719000 [sec]
quick_sort : 0.766000 [sec]
counting_sort : 0.765000 [sec]
counting_sort2 : 1.234000 [sec]
counting_sort3 : 1.188000 [sec]
radix_sort : 0.797000 [sec]
radix_sort2 : 0.640000 [sec]
radix_sort3 : 0.563000 [sec]
radix_sort4 : 0.390000 [sec]
次ã¯ãç»åå¦çåãã®é«éãªmemcmpãmemcpyãbzeroãããããã£ã¦ã¿ã¾ãããããã
bswap
ä»æ¥ã®ã³ã¼ããWindows XPã¨Mac OS X 10.6.8ã§åä½ãããã¨ã確èªãã¦ãã¾ãã
ãã¤ããªããã°ã©ãã³ã°ããã£ã¦ããã¨ãã¨ã³ãã£ã¢ã³ã«å¿ãã¦ãã¤ããªã¼ãã¼ãã²ã£ããè¿ãï¼ãã¤ãã¹ã¯ããï¼ã¨ããã®ãããããã¾ãããã¤ãã¹ã¯ããã¯é«éã«ãããã¨æãã¨ä¸ã
åä»ã§ããã¯ãã«ããã¨åããã¥ããããã©ã¤ãã©ãªé¢æ°ã«ããã¨ã¤ã³ã©ã¤ã³å±éãå¹ããªããªãã¾ããã¨ããããã§ããæ¹æ³ããªãã®ãå°ãã ã調ã¹ã¦ã¿ã¾ããã
- http://d.hatena.ne.jp/NyaRuRu/20050617/p2
- http://www.shudo.net/diary/2005jun.html#20050615
- http://qune.cside.com/archives/001572.html
- http://d.hatena.ne.jp/mhiki/20100929/1285767996
- http://d.hatena.ne.jp/eggtoothcroc/20111115/p1
ããã¾ã§ã®ã¾ã¨ãã
- x86ã¨ããã80486ã§ã¯ãCPUã«bswapå½ä»¤ãããã®ã§ããã使ãã¨ãã*1
- htonlãhtonsãntohlãntohsé¢æ°ã使ãã¨bswapå½ä»¤ã使ã£ã¦ããããã¨ããã
- Visual Studioã®stdlib.hã«ã¯ãã¤ãã¹ã¯ããã®ããã®é¢æ°ç¾¤ã容æããã¦ãã*2
- ãããã«ã³ã¼ããæ¸ãã¦ãã¾ãã°ã¤ã³ã©ã¤ã³å±éãå¹ã
ãªããªãé¢åããã ãªãã¨ãããã¨ãåããã¾ãããã§ãããããªãããããã¨ã¯èª°ãããã¾ããã¨ãã£ã¦ããã¦ããã¯ãã§ããã¨ãããã¨ã§ããã«èª¿ã¹ã¦ã¿ãã¨ã以ä¸ã®ãããªã³ã¼ããè¦ã¤ããã¾ããã
- http://code.google.com/p/crusher264/source/browse/trunk/sample/bswap.h?r=51
- http://code.google.com/p/youtube-mobile-ffmpeg/source/browse/trunk/libavutil/bswap.h?r=8
- http://www.hackchina.com/en/r/179738/bswap.h__html
ã³ã¼ããçºãã¦ã¿ãã¨ä»¥ä¸ã®ããã«ãªã£ã¦ããããã§ãã
- ARMãx86ãx86_64ã®å ´åã¯å°ç¨ã®CPUå½ä»¤ãå¼ã³åºã
- ãããã«ã³ã¼ããæ¸ãã¦ã¤ã³ã©ã¤ã³å±éãå¹ãããã«ãã¦ãã
- ç¥ããªãCPUã«å¯¾ãã¦ã¯æ®éã«Cã®ã³ã¼ããå¼ã³åºã
Cã ãã§æ¸ããªããããªæãã§ãããã«æ¸ãã®ãå®ç³ã¿ããã§ãããã¾ãã§éæ³ã®ããã§ãããèªåã§è¨ç®ãã¦ãã³ã³ãã¤ã«ãã¦å®è¡ãã¦ãã¡ããã¨åãã¾ããç¹ã«ãbswap_32ãå³ã·ãããå·¦ã·ãããè«çåãè«çç©ããã¹ã¦äºåãã¤ãªã®ã§ã¨ã¦ãç¾ããæãããã¾ãã
static inline uint16_t bswap_16(uint16_t x) { return (x >> 8) | (x << 8); } static inline uint32_t bswap_32(uint32_t x) { x= ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0x00FF00FF); return (x >> 16) | (x << 16); } static inline uint64_t bswap_64(uint64_t x) { union { uint64_t ll; uint32_t l[2]; } w, r; w.ll = x; r.l[0] = bswap_32 (w.l[1]); r.l[1] = bswap_32 (w.l[0]); return r.ll; }
bswap_32ãæ®éã«èãããããã§ãããã
static inline uint32_t bswap_32(uint32_t x) { return (((x & 0x000000ff) >> 0x00) << 0x18) | (((x & 0x0000ff00) >> 0x08) << 0x10) | (((x & 0x00ff0000) >> 0x10) << 0x08) | (((x & 0xff000000) >> 0x18) << 0x00); }
ãã§ããããªã£ã¦ã»ã»ã»
static inline uint32_t bswap_32(uint32_t x) { return ((x & 0x000000ff) << 0x18) | ((x & 0x0000ff00) << 0x08) | ((x & 0x00ff0000) >> 0x08) | ((x & 0xff000000) >> 0x18); }
ããã§ãããã
static inline uint32_t bswap_32(uint32_t x) { return (x << 0x18) | ((x & 0x0000ff00) << 0x08) | ((x & 0x00ff0000) >> 0x08) | (x >> 0x18); }
ãã£ãã®bswap_32ããããè«çåãä¸åå¤ããªãã¾ããããã ãã§ããã©ããããæ¸ãããã£ã¦ã®ããã£ãã®bswap_32ã®ãããã¨ãããGraphic Gems Iã«ã¯ãããããã¨ãä¸æ¯æ¸ãã¦ããããã ãªã
Graphics Gems (Graphics Gems - IBM)
- ä½è : Andrew S. Glassner
- åºç社/ã¡ã¼ã«ã¼: Morgan Kaufmann
- çºå£²æ¥: 1990/06/01
- ã¡ãã£ã¢: ãã¼ãã«ãã¼
- ã¯ãªãã¯: 24å
- ãã®ååãå«ãããã° (1件) ãè¦ã
Topological sort
ãããã¸ã«ã«ã½ã¼ã*1ãæ¸ãã¦ã¿ã¾ãããCè¨èªãDè¨èªãLuaãRubyã§ã
ãããã¸ã«ã«ã½ã¼ããä½ã«ä½¿ãããã¨ããã¨ãmakeã®ä¾åæ§è§£æ±ºãªã©ã§ä½¿ãã¾ããyamakeã¨ãããã«ãã·ã¹ãã ãä½ãä¸ã§ãåèã«ãã¦ããã·ã¹ãã ã¨ãã¦ninja*2ã®ã½ã¼ã¹ã³ã¼ããè¦ã¦ããã®ã§ãããèªåã§ãã§ãããã ã¨æã£ã¦ãã£ã¦ã¿ã¾ãããninjaã§ã¯ãããã¸ã«ã«ã½ã¼ãã£ã½ããã¨ã¯ãã£ã¦ã¾ãããã
å®è£ ã¯ç°¡åã§ããããä¾åæ§è§£æ±ºã«ãããã¸ã«ã«ã½ã¼ãã使ããã¨ãããã¨ãæ¢ãã¾ã§ã«å°ãæéããããã¾ãããæåã¯å¾ªç°åç §æ¤åº*3ã®Floyd's cycle-finding algorithmã«ãã©ãçãã¾ããããmakeã®ä¾åæ§ã®ãããªäºæ¬¡ã®ãã®ã«ã¯å¯¾å¿ã§ããªãã®ã§ããã«æ¢ãã¦ããããªãã¨ãè¦ã¤ãã£ãã¨ããæãã§ãã