janodvarko / harviewer

HAR Viewer is a web application that allows visualizing HTTP Archive logs (HARs)
http://www.softwareishard.com/blog/har-viewer/
1.04k stars 184 forks source link

Syntax highlighting can be slow with large(ish) resources #135

Closed gitgrimbo closed 6 years ago

gitgrimbo commented 6 years ago

E.g. saving a HAR from https://reactjs.org/, clicking on the https://unpkg.com/babel-standalone@6.26.0/babel.min.js resource (a 772.7 KB JS resource), and clicking on the "Highlighted" tab:

At the moment the advice for avoiding slowdowns is don't click on the Highlighted tab for large resources, unless you are willing to wait.


Indicative times

Machine: AMD Ryzen 5 1600, 16 GB DDR4 RAM.

Browser Time
Chrome 70 ~7.35 seconds.
Firefox 63.0.1 ~9.47 seconds.
IE 11 ~11.43 seconds.

Possibly try other highlighters, e.g. Prism.

gitgrimbo commented 6 years ago

See https://gitgrimbo.github.io/syntax-highlighting-performance/ for comparisons.

Some initial thoughts (based on highlighting some well-known JS library files - using the above URL - and Chrome 70):

Note 1 that 'slowness' is based on large resources. These libraries probably aren't intended to highlight large resources, such as https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.0/cjs/react-dom.development.js (692,446 bytes).

For smaller resources, e.g. https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js (51,039 bytes), every library except Rainbow performed well enough, i.e. sub-second.

Note 2 - IE 11's performance is mostly hideous for everything, and IE 11 performance shouldn't influence any decision.

gitgrimbo commented 6 years ago

Chrome 70

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36

lib total time HL time res. size HL time/1000B resource url
Prism 1.15.0 19 14 1186 11.804 https://unpkg.com/reset-css@4.0.1/reset.css
SyntaxHighlighter 3.0.83 36 36 1186 30.354 https://unpkg.com/reset-css@4.0.1/reset.css
highlight.js 9.13.1 18 16 1186 13.490 https://unpkg.com/reset-css@4.0.1/reset.css
Rainbow 2.1.4 49 48 1186 40.472 https://unpkg.com/reset-css@4.0.1/reset.css
Prism 1.15.0 241 241 51039 4.721 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js
SyntaxHighlighter 3.0.83 196 193 51039 3.781 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js
highlight.js 9.13.1 126 125 51039 2.449 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js
Rainbow 2.1.4 2381 2380 51039 46.631 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js
Prism 1.15.0 431 431 86452 4.985 https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js
SyntaxHighlighter 3.0.83 223 222 86452 2.567 https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js
highlight.js 9.13.1 265 265 86452 3.065 https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js
Rainbow 2.1.4 19718 19718 86452 228.080 https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js
Prism 1.15.0 705 701 100389 6.982 https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.0/cjs/react-dom.production.min.js
SyntaxHighlighter 3.0.83 455 453 100389 4.512 https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.0/cjs/react-dom.production.min.js
highlight.js 9.13.1 279 279 100389 2.779 https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.0/cjs/react-dom.production.min.js
Rainbow 2.1.4 41970 41969 100389 418.063 https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.0/cjs/react-dom.production.min.js
Prism 1.15.0 410 409 123765 3.304 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.js
SyntaxHighlighter 3.0.83 432 432 123765 3.490 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.js
highlight.js 9.13.1 146 146 123765 1.179 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.js
Rainbow 2.1.4 18187 18186 123765 146.939 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.js
Prism 1.15.0 227 226 140936 1.603 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css
SyntaxHighlighter 3.0.83 848 846 140936 6.002 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css
highlight.js 9.13.1 189 187 140936 1.326 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css
Rainbow 2.1.4 16887 16887 140936 119.820 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css
Prism 1.15.0 270 269 173597 1.549 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css
SyntaxHighlighter 3.0.83 1129 1128 173597 6.497 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css
highlight.js 9.13.1 209 208 173597 1.198 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css
Rainbow 2.1.4 38229 38228 173597 220.211 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css
Prism 1.15.0 851 849 289303 2.934 https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js
SyntaxHighlighter 3.0.83 945 944 289303 3.263 https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js
highlight.js 9.13.1 270 268 289303 0.926 https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js
Rainbow 2.1.4 69499 69498 289303 240.225 https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js
Prism 1.15.0 21828 21823 517324 42.184 https://cdnjs.cloudflare.com/ajax/libs/babel-core/6.1.19/browser.min.js
SyntaxHighlighter 3.0.83 1620 1615 517324 3.121 https://cdnjs.cloudflare.com/ajax/libs/babel-core/6.1.19/browser.min.js
highlight.js 9.13.1 1063 1061 517324 2.050 https://cdnjs.cloudflare.com/ajax/libs/babel-core/6.1.19/browser.min.js
Rainbow 2.1.4 867353 867351 517324 1676.610 https://cdnjs.cloudflare.com/ajax/libs/babel-core/6.1.19/browser.min.js
Prism 1.15.0 8045 8043 692446 11.615 https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.0/cjs/react-dom.development.js
SyntaxHighlighter 3.0.83 2524 2524 692446 3.645 https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.0/cjs/react-dom.development.js
highlight.js 9.13.1 534 532 692446 0.768 https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.0/cjs/react-dom.development.js
Rainbow 2.1.4 278431 278430 692446 402.096 https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.0/cjs/react-dom.development.js
gitgrimbo commented 6 years ago

IE 11

Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; rv:11.0) like Gecko

lib total time HL time res. size HL time/1000B resource url
Prism 1.15.0 11 7 1186 5.902 https://unpkg.com/reset-css@4.0.1/reset.css
SyntaxHighlighter 3.0.83 49 47 1186 39.629 https://unpkg.com/reset-css@4.0.1/reset.css
highlight.js 9.13.1 13 10 1186 8.431 https://unpkg.com/reset-css@4.0.1/reset.css
Rainbow 2.1.4 50 43 1186 36.256 https://unpkg.com/reset-css@4.0.1/reset.css
Prism 1.15.0 328 326 51039 6.387 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js
SyntaxHighlighter 3.0.83 188 185 51039 3.624 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js
highlight.js 9.13.1 370 368 51039 7.210 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js
Rainbow 2.1.4 3237 3234 51039 63.363 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js
Prism 1.15.0 597 595 86452 6.882 https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js
SyntaxHighlighter 3.0.83 292 288 86452 3.331 https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js
highlight.js 9.13.1 1135 1133 86452 13.105 https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js
Rainbow 2.1.4 32191 32188 86452 372.322 https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js
Prism 1.15.0 673 670 100389 6.674 https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.0/cjs/react-dom.production.min.js
SyntaxHighlighter 3.0.83 456 452 100389 4.502 https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.0/cjs/react-dom.production.min.js
highlight.js 9.13.1 622 619 100389 6.166 https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.0/cjs/react-dom.production.min.js
Rainbow 2.1.4 64442 64438 100389 641.883 https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.0/cjs/react-dom.production.min.js
Prism 1.15.0 401 397 123765 3.207 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.js
SyntaxHighlighter 3.0.83 398 397 123765 3.207 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.js
highlight.js 9.13.1 337 334 123765 2.698 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.js
Rainbow 2.1.4 20323 20320 123765 164.182 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.js
Prism 1.15.0 395 382 140936 2.710 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css
SyntaxHighlighter 3.0.83 2521 2512 140936 17.823 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css
highlight.js 9.13.1 436 430 140936 3.051 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css
Rainbow 2.1.4 25704 25697 140936 182.330 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css
Prism 1.15.0 518 507 173597 2.920 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css
SyntaxHighlighter 3.0.83 3159 3150 173597 18.145 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css
highlight.js 9.13.1 444 435 173597 2.505 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css
Rainbow 2.1.4 59056 59044 173597 340.121 https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.css
Prism 1.15.0 1049 1045 289303 3.612 https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js
SyntaxHighlighter 3.0.83 1122 1118 289303 3.864 https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js
highlight.js 9.13.1 776 771 289303 2.665 https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js
Rainbow 2.1.4 92739 92732 289303 320.535 https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js
Prism 1.15.0 5086 5073 517324 9.806 https://cdnjs.cloudflare.com/ajax/libs/babel-core/6.1.19/browser.min.js
SyntaxHighlighter 3.0.83 1620 1607 517324 3.106 https://cdnjs.cloudflare.com/ajax/libs/babel-core/6.1.19/browser.min.js
highlight.js 9.13.1 3352 3344 517324 6.464 https://cdnjs.cloudflare.com/ajax/libs/babel-core/6.1.19/browser.min.js
Rainbow 2.1.4 857727 857716 517324 1657.986 https://cdnjs.cloudflare.com/ajax/libs/babel-core/6.1.19/browser.min.js
Prism 1.15.0 3567 3553 692446 5.131 https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.0/cjs/react-dom.development.js
SyntaxHighlighter 3.0.83 2533 2524 692446 3.645 https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.0/cjs/react-dom.development.js
highlight.js 9.13.1 1395 1376 692446 1.987 https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.0/cjs/react-dom.development.js