<!doctype html><htmllang=en-us><head><metacharset=utf-8><metahttp-equiv=x-ua-compatiblecontent="ie=edge"><metaname=viewportcontent="width=device-width,initial-scale=1,shrink-to-fit=no"><linkrel=preloadas=fonthref=/fonts/vendor/jost/jost-v4-latin-regular.woff2type=font/woff2crossorigin><linkrel=preloadas=fonthref=/fonts/vendor/jost/jost-v4-latin-700.woff2type=font/woff2crossorigin><linkrel=stylesheethref=/main.7a413a9a97a3360893a7e50ee5892da80e0f60349c21739810858ee555d5270e89e0c97966ba1460d57cb94acdf9f6b06e0c8dc2e4fca17a8b59c438b9200f3e.cssintegrity="sha512-ekE6mpejNgiTp+UO5YktqA4PYDScIXOYEIWO5VXVJw6J4Ml5ZroUYNV8uUrN+fawbgyNwuT8oXqLWcQ4uSAPPg=="crossorigin=anonymous><noscript><style>img.lazyload{display:none}</style></noscript><metaname=robotscontent="index, follow"><metaname=googlebotcontent="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"><metaname=bingbotcontent="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"><title>PoW performance - mCaptcha</title><metaname=descriptioncontent="PoW performance of native and WASM implementations. Does the native implementation have and edge over the WASM library?"><linkrel=canonicalhref=/blog/pow-performance/><metaname=twitter:cardcontent="summary_large_image"><metaname=twitter:imagecontent="/blog/pow-performance/icon.png"><metaname=twitter:titlecontent="PoW performance"><metaname=twitter:descriptioncontent="PoW performance of native and WASM implementations. Does the native implementation have and edge over the WASM library?"><metaname=twitter:sitecontent="@"><metaname=twitter:creatorcontent="@"><metaproperty="og:title"content="PoW performance"><metaproperty="og:description"content="PoW performance of native and WASM implementations. Does the native implementation have and edge over the WASM library?"><metaproperty="og:type"content="article"><metaproperty="og:url"content="/blog/pow-performance/"><metaproperty="og:image"content="/blog/pow-performance/icon.png"><metaproperty="article:published_time"content="2021-09-01T00:00:00+00:00"><metaproperty="article:modified_time"content="2021-09-01T15:33:12+05:30"><metaproperty="og:site_name"content="mCaptcha"><metaproperty="article:publisher"content="https://www.facebook.com/"><metaproperty="article:author"content="https://www.facebook.com/"><metaproperty="og:locale"content="en_US"><scripttype=application/ld+json>{"@context":"http://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"\/"},{"@type":"ListItem","position":2,"name":"Blogpow Performance","item":"\/blogpow-performance\/"}]}</script><metaname=theme-colorcontent="#fff"><linkrel=apple-touch-iconsizes=180x180href=/apple-touch-icon.png><linkrel=icontype=image/pngsizes=32x32href=/favicon-32x32.png><linkrel=icontype=image/pngsizes=16x16href=/favicon-16x16.png><linkrel=manifesthref=/site.webmanifest></head><bodyclass="blog single"><divclass="header-bar fixed-top"></div><headerclass="navbar fixed-top navbar-expand-md navbar-light"><divclass=container><inputclass="menu-btn order-0"type=checkboxid=menu-btn>
usually use browsers to access a website.</p><p>I wanted to see how much of an advantage a native program would have
over our WASM library.</p><h2id=benchmark-tools>Benchmark tools</h2><p>So I wrote these to compare native and WASM performances:</p><ul><li>Browser benchmark: <ahref=https://mCaptcha.github.io/benches>https://mCaptcha.github.io/benches</a></li><li>Native benchmark: <ahref=https://github.com/mCaptcha/cli/blob/master/scripts/bench.sh>mCaptcha/cli managed by scripts/bench.sh</a></li></ul><divclass="alert alert-warning d-flex"role=alert><divclass="flex-shrink-1 alert-icon">⭐</div><divclass=w-100>Feel free to reproduce the results!</div></div><h2id=results>Results</h2><p>The tests were run on my development machine featuring an Intel Core
i7-9750h.</p><h3id=native>Native</h3><table><thead><tr><th>Difficulty</th><th>Real</th><th>User</th><th>Sys</th></tr></thead><tbody><tr><td>500000</td><td>0m0.220s</td><td>0m0.197s</td><td>0m0.006s</td></tr><tr><td>1000000</td><td>0m0.203s</td><td>0m0.203s</td><td>0m0.000s</td></tr><tr><td>1500000</td><td>0m0.198s</td><td>0m0.198s</td><td>0m0.000s</td></tr><tr><td>2000000</td><td>0m0.203s</td><td>0m0.203s</td><td>0m0.000s</td></tr><tr><td>2500000</td><td>0m0.758s</td><td>0m0.752s</td><td>0m0.003s</td></tr><tr><td>3000000</td><td>0m0.776s</td><td>0m0.769s</td><td>0m0.003s</td></tr><tr><td>3500000</td><td>0m2.010s</td><td>0m1.998s</td><td>0m0.000s</td></tr><tr><td>4000000</td><td>0m2.038s</td><td>0m2.033s</td><td>0m0.003s</td></tr><tr><td>4500000</td><td>0m2.014s</td><td>0m2.013s</td><td>0m0.000s</td></tr></tbody></table><h3id=browser>Browser</h3><p>I ran the tests on both Firefox and Chromium to compare results</p><h3id=firefox>Firefox</h3><ul><li><strong>User Agent:</strong><code>Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0</code></li><li><strong>Hardware concurrency:</strong> 12</li></ul><table><thead><tr><th>Difficulty</th><th>Duration(in ms)</th></tr></thead><tbody><tr><td>500000</td><td>401</td></tr><tr><td>1000000</td><td>413</td></tr><tr><td>1500000</td><td>398</td></tr><tr><td>2000000</td><td>394</td></tr><tr><td>2500000</td><td>1495</td></tr><tr><td>3000000</td><td>1556</td></tr><tr><td>3500000</td><td>3971</td></tr><tr><td>4000000</td><td>4235</td></tr><tr><td>4500000</td><td>4116</td></tr></tbody></table><blockquote><p>To be fair, my Firefox installation is loaded with a gazillion
much</p></blockquote><h4id=chromium>Chromium</h4><ul><li><strong>User Agent:</strong><code>Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36</code></li><li><strong>Hardware concurrency:</strong> 12</li></ul><table><thead><tr><th>Difficulty</th><th>Duration(in ms)</th></tr></thead><tbody><tr><td>500000</td><td>399.40000000037253</td></tr><tr><td>1000000</td><td>354.6000000014901</td></tr><tr><td>1500000</td><td>351.19999999925494</td></tr><tr><td>2000000</td><td>353.80000000074506</td></tr><tr><td>2500000</td><td>1337.800000000745</td></tr><tr><td>3000000</td><td>1311.199999999255</td></tr><tr><td>3500000</td><td>3417.5999999996275</td></tr><tr><td>4000000</td><td>3488.800000000745</td></tr><tr><td>4500000</td><td>3458.2999999988824</td></tr></tbody></table><h2id=conclusion>Conclusion</h2><p>At the highest difficulty factor, the native implementation was a almost second