-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
1212 lines (1071 loc) · 49.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html><html><head>
<title>
CSharpWasmBenchmark
</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/fonts/remixicon.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" crossorigin="anonymous">
<link rel="stylesheet" href="https://hyper-nav.acmion.com/+/dist/css/hyper-nav-default.min.css">
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script><style id="plotly.js-style-global"></style>
<script src="/Source/CSharpWasmBenchmark/wwwroot/js/benchmark-data-plotter.js"></script>
<script src="/Source/CSharpWasmBenchmark/wwwroot/js/file-handler.js"></script>
<script src="/Source/CSharpWasmBenchmark/wwwroot/js/math-functions.js"></script>
<script src="/Source/CSharpWasmBenchmark/wwwroot/js/nameof.js"></script>
<link rel="stylesheet" href="/Source/CSharpWasmBenchmark/wwwroot/css/main.css">
</head><body>
<header>
<nav class="hn-menu hn-top hn-fixed hn-shadow">
<input type="checkbox" name="hn-top-state" class="hn-input-state hn-input-state-nav hn-hide-desktop" id="hn-nav-cb">
<div class="hn-nav container-md p-0">
<div class="hn-section hn-section-brand">
<div class="hn-item">
<a id="hn-logo" class="hn-link" href="/">
<span class="hn-content">
<span class="acmion-logo" style="font-weight: 600;">
CSharpWasmBenchmark
</span>
</span>
</a>
</div>
<div class="hn-spacer"></div>
<label class="hn-item hn-input hn-input-nav hn-hide-desktop" for="hn-nav-cb">
<span class="hn-link">
<span class="hn-content">
<span class="hn-input-active ">
<i class="ri-close-line"></i>
</span>
<span class="hn-input-default">
<i class="ri-menu-line"></i>
</span>
</span>
</span>
</label>
</div>
<div class="hn-section hn-section-body">
<div class="hn-spacer"></div>
<div class="hn-item">
<a class="hn-link" href="#home">
<span class="hn-content">
Home
</span>
</a>
</div>
<div class="hn-item">
<a class="hn-link" href="#conclusions">
<span class="hn-content">
Conclusions
</span>
</a>
</div>
<div class="hn-item">
<a class="hn-link" href="#credits">
<span class="hn-content">
Credits
</span>
</a>
</div>
<div class="hn-item">
<a class="hn-link" href="#benchmarking-strategy">
<span class="hn-content">
Benchmarking Strategy
</span>
</a>
</div>
<div class="hn-item">
<a class="hn-link" href="#benchmarks">
<span class="hn-content">
Benchmarks
</span>
</a>
</div>
<div class="hn-item">
<a class="hn-link" href="https://github.com/Acmion/CSharpWasmBenchmark">
<span class="hn-content">
GitHub
</span>
</a>
</div>
</div>
</div>
<label class="hn-overlay" for="hn-nav-cb">
</label>
</nav>
</header>
<div class="scroll-anchor-height"></div>
<main class="container">
<h1 class="scroll-anchor" id="home">
CSharpWasmBenchmark - Results
</h1>
<p>
CSharpWasmBenchmark is a project that benchmarks the performance of C# when compiled to Webassembly.
The rationale behind this analysis is to find out whether it is viable to run performance critical applications
written in C# in the browser and how the browser performance differs from "native" performance.
</p>
<p>
The performance of the following are measured: C# Runtime, C# Wasm AOT Blazor, C# Wasm Interpreted Blazor, C Wasm
and JavaScript. This C# code has been compiled with .NET 7.
</p>
<p>
Improvements can probably be expected to C# Wasm in the future.
</p>
<p>
The JavaScript code is directly translated (as well as possible) from the C# source code,
which may create certain differences between the implications of the code that is executed. You should
always compare the source codes! The comparison between the performance of different C# execution targets
are likely more reliable than that of comparison with JavaScript. JavaScript was included in this analysis
since currently it is the standard frontend development programming language.
</p>
<p>
<strong>Note:</strong> The benchmarks may have errors in them and the source codes may
not be equivalent. However, the C# code is always executed from the same source and should thus be comparable.
Additionally, since C# Wasm AOT and Wasm itself are still somewhat experimental technologies, these results may not reflect
the performance of the finalized product.
</p>
<p>
Unfortunately Blazor Wasm threw some memory error for larger parameter values. I do not currently have the time to investigate
this and as such I just decreased the magnitude of the parameters. Note that the executed code is just the same for
C# runtime and both C# Blazor variants.
</p>
<section>
<h2 class="scroll-anchor" id="conclusions">
Conclusions
</h2>
<style>
#conclusions-table td:nth-child(2),
#conclusions-table td:nth-child(3),
#conclusions-table th:nth-child(2),
#conclusions-table th:nth-child(3)
{
text-align: end;
}
</style>
<table class="table" id="conclusions-table" style="border: 1px solid #dee2e6">
<thead>
<tr>
<th>
Platform
</th>
<th>
Total Time Spent in Benchmarks (ms)
</th>
<th>
Relative Performance
</th>
</tr>
</thead>
<tbody id="conclusions-table-body">
<tr><td>Loading...</td></tr>
</tbody>
</table>
<p>
<strong>Table 1:</strong> The total time spent in all the benchmarks.
This data can be interpreted to give some sort of an average estimate of how well the different
platforms perform. However, the performance depends on the parameter values.
See the figures below for a more detailed overview.
</p>
<p>
The performance of C# AOT compiled to Webassembly is often significantly better than that of C# Wasm Interpreted.
Table 1 shows the total time spent in benchmarking each platform. Running the benchmarks in C# Wasm AOT takes approximately
<strong>2.69x</strong> longer than in the C# runtime and running the benchmarks in C# Wasm Interpreted takes
approximately <strong>33.19x</strong> longer than in the C# runtime.
These values are rough estimates and depend on parameter values. See more details in the figures below.
</p>
<p>
Generally the performance improvement of AOT in the featured benchmarks lies within the range <strong>2x - 5x</strong>,
but in some cases even a <strong>20x</strong> performance benefit can be seen. Strangely, for example,
sorting doubles seems to be slightly slower with AOT code.
</p>
<p>
C# Runtime can in some cases perform over <strong>30x</strong> (even faster in certain cases) faster than C# Wasm AOT. However, the
performance is almost on par in some cases with C# Wasm AOT. Probably when no abstractions or framework calls
are utilized. See for example the C# Wasm AOT performance difference between ArraySortInt (uses Array.Sort) and
ArraySortIntQuick (uses a custom quicksort implementation). The performance of ArraySortIntQuick in C# Wasm AOT is about
<strong>20x</strong> better than that of ArraySortInt, even if they, in practice, do the same work.
The performance difference between ArraySortInt and ArraySortIntQuick when executing under the C# Runtime is negligible.
</p>
<p>
The equivalent code executed as JavaScript is generally faster than
C# Wasm AOT. However, if the code avoids relying on framework methods and calls (for example
ArraySortIntQuick, NewtonsMethodSecondDegree and NewtonsMethodThirdDegree) then the difference
is almost negligible.
</p>
<p>
Webassembly promises, more or less, that it can enable "native" performance within a browser. C# often
runs within a virtual machine and can maybe thus not achieve the full potential of Wasm. However,
the difference in performance between C# Runtime and C# Wasm AOT varies from benchmark to benchmark and
does generally not live up to the promise of Webassembly. Even JS is often faster than C# Wasm AOT.
With the benchmarks and assumptions of this project the conclusion is that
<strong>
C# Wasm AOT still has a long way to become a general and performant client side web programming platform.
Hopefully this changes in the future.
</strong>
</p>
</section>
<section>
<h2 class="scroll-anchor" id="credits">
Credits
</h2>
<p>
This analysis initially created by <a href="https://acmion.com">Acmion</a>.
</p>
<p>
Contribute to CSharpWasmBenchmark in it's <a href="https://github.com/Acmion/CSharpWasmBenchmark">GitHub repository</a>.
Consider leaving a like if you found this analysis useful, interesting or informative.
</p>
<p>
Thanks to <a href="https://github.com/gabrielgt">gabrielgt</a> for his contributions in updating the project to .NET 7 and
the C Wasm implementation.
</p>
<p>
Thanks to <a href="https://github.com/unoplatform/Uno.Wasm.Bootstrap">Uno.Wasm.Bootstrap</a>, a project that provides
an understandable way of AOT compiling C# to Wasm that just works and has minimal dependencies. Uno.Wasm.Bootstrap is
no longer used in this benchmark, but for a long time it was used for C# Wasm AOT.
</p>
</section>
<section>
<h2 class="scroll-anchor" id="benchmarking-strategy">
Benchmarking Strategy
</h2>
<p>
This section describes how the benchmarks are created and executed. All benchmarks are contained within some
categories, for example, there is an <code>ArrayBenchmarks</code> and a <code>ListBenchmarks</code> category.
BenchmarkDotNet was not utilized in this project, because I wanted to ensure that the C# and JavaScript code
and benchmarks are doing the same things. Additionally, BenchmarkDotNet uses some complex compilation strategies,
which may or may not work with C# Wasm AOT.
</p>
<section class="indent">
<h3>
C# Benchmarks
</h3>
<p>
The source code of the C# benchmark executer can be found <a href="/Benchmarking/Core/BenchmarkRunner.cs">here</a>.
The way a C# benchmark should be defined is:
</p>
<p>
</p><ol>
<li>
Create a C# class <code>SomeBenchmark</code>, which inherits from <code>Benchmark</code>.
</li>
<li>
Override some describing properties.
</li>
<li>
Override the <code>Parameters</code> property, which is of type <code>int[]</code>.
<code>SomeBenchmark</code> is initialized and executed with each of the values of <code>Parameters</code>.
This means that the performance of something can be evaulated with several parameter values. For example,
if <code>Parameters = new int[] { 1, 10, 100, 1000 }</code> and <code>SomeBenchmark</code> sorts a list
of numbers, then the analysis can be evaluated for a list of length 1, a list of length 10, a list of length
100 and a list of length 1000.
</li>
<li>
Override the <code>public void Initialize(int parameter)</code> method. The value of <code>parameter</code> is one
value from the <code>Parameters</code> array. This method is used to initialize stuff needed for the
benchmark, but the performance is not evaluated.
</li>
<li>
Override the <code>public object Execute()</code> method. This method should execute the code that is to be
benchmarked. The method returns an <code>object</code>, which main purpose should be to ensure that the compiler
does not remove the code within the method. The performance of this method is evaluated.
</li>
<li>
Register <code>SomeBenchmark</code> under a <code>BenchmarkCategory</code> in <code>Benchmarking/Core/BenchmarkCategory.cs</code>.
Note that you may need to define an extra category.
</li>
</ol>
<p></p>
</section>
<section class="indent">
<h3>
JavaScript Benchmarks
</h3>
<p>
The source code of the JS benchmark executer can be found <a href="/Benchmarking/JavaScriptCore/BenchmarkRunner.js">here</a>.
The way a JS benchmark should be defined is:
</p>
<p>
</p><ol>
<li>
Create a JavaScript class <code>SomeBenchmark</code>. Note that the class name should be the same
as the C# class name.
</li>
<li>
No need to override describing properties. The values from C# are dynamically injected wherever needed.
</li>
<li>
No need to define a <code>Parameters</code> array. The value from C# is dynamically injected wherever needed.
</li>
<li>
Define the <code>function Initialize(parameter)</code> function. The behavior should be the same as the C# equivalent.
This performance is not evaluated.
</li>
<li>
Define the <code>function Execute()</code> function. The behavior should be the same as the C# equivalent.
This performance is evaluated.
</li>
<li>
No need to register this class anywhere. It is dynamically injected wherever needed.
</li>
</ol>
<p></p>
</section>
<section class="indent">
<h3>
Benchmark Plots
</h3>
<p>
Each benchmark is executed a certain number of times for each parameter value. The mean execution times of these runs
represent data points, while the standard deviations represent error bars.
</p>
</section>
</section>
<section>
<h2 class="scroll-anchor" id="benchmarks">
Benchmarks
</h2>
<div class="indent">
<p>
The benchmarks.
</p>
<div>
<section>
<h3 class="d-flex">
ArrayBenchmarks
</h3>
<p>
The benchmarks related to this category.
</p>
<div>
<section class="indent">
<h4>
ArraySortInt
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br> Generates an array of random ints.
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Sorts the array.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The middle value of the sorted array.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The length of the array that is sorted.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/ArraySortInt.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/ArraySortInt.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/ArraySortInt.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="ArraySortInt" class="js-plotly-plot"></div>
</div>
</section>
<section class="indent">
<h4>
ArraySortDouble
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br> Generates an array of random doubles.
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Sorts the array.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The middle value of the sorted array.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The length of the array that is sorted.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/ArraySortDouble.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/ArraySortDouble.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/ArraySortDouble.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="ArraySortDouble" class="js-plotly-plot"></div>
</div>
</section>
<section class="indent">
<h4>
ArraySortIntQuick
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br> Generates an array of random ints.
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Sorts the array with a custom implemented Middle Point Pivot Quicksort <a href="https://github.com/TheAlgorithms/C-Sharp">(source)</a>.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The middle value of the sorted array.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The length of the array that is sorted.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/ArraySortIntQuick.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/ArraySortIntQuick.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/ArraySortIntQuick.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="ArraySortIntQuick" class="js-plotly-plot"></div>
</div>
</section>
</div>
</section>
</div>
<div>
<section>
<h3 class="d-flex">
ListBenchmarks
</h3>
<p>
The benchmarks related to this category.
</p>
<div>
<section class="indent">
<h4>
ListSortInt
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br> Generates a list of random ints.
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Sorts the list.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The middle value of the sorted list.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The length of the list.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/ListSortInt.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/ListSortInt.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/ListSortInt.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="ListSortInt" class="js-plotly-plot"></div>
</div>
</section>
<section class="indent">
<h4>
ListSortDouble
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br> Generates a list of random doubles.
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Sorts the list.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The middle value of the sorted list.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The length of the list.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/ListSortDouble.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/ListSortDouble.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/ListSortDouble.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="ListSortDouble" class="js-plotly-plot"></div>
</div>
</section>
<section class="indent">
<h4>
ListInsert
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br> Generates a list of random ints.
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Inserts 20% more values to the beginning of the list.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The middle value of the list.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The length of the list.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/ListInsert.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/ListInsert.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/ListInsert.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="ListInsert" class="js-plotly-plot"></div>
</div>
</section>
<section class="indent">
<h4>
ListDelete
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br> Generates a list of random ints.
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Deletes 20% of the values from the beginning of the list.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The middle value of the list.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The length of the list.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/ListDelete.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/ListDelete.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/ListDelete.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="ListDelete" class="js-plotly-plot"></div>
</div>
</section>
</div>
</section>
</div>
<div>
<section>
<h3 class="d-flex">
MathBenchmarks
</h3>
<p>
The benchmarks related to this category.
</p>
<div>
<section class="indent">
<h4>
SummationInt
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br> Generates a list of random ints.
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Sums each number of the list.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The result of the summation.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The number of ints to sum.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/SummationInt.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/SummationInt.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/SummationInt.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="SummationInt" class="js-plotly-plot"></div>
</div>
</section>
<section class="indent">
<h4>
SummationDouble
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br> Generates a list of random doubles.
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Sums each number of the list.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The result of the summation.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The number of doubles to sum.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/SummationDouble.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/SummationDouble.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/SummationDouble.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="SummationDouble" class="js-plotly-plot"></div>
</div>
</section>
<section class="indent">
<h4>
MultiplicationInt
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br> Generates a list of random ints.
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Multiplies each number of the list.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The result of the multiplication.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The number of ints to multiply.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/MultiplicationInt.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/MultiplicationInt.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/MultiplicationInt.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="MultiplicationInt" class="js-plotly-plot"></div>
</div>
</section>
<section class="indent">
<h4>
MultiplicationDouble
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br> Generates a list of random doubles.
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Multiplies each number of the list.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The result of the multiplication.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The number of doubles to multiply.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/MultiplicationDouble.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/MultiplicationDouble.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/MultiplicationDouble.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="MultiplicationDouble" class="js-plotly-plot"></div>
</div>
</section>
<section class="indent">
<h4>
NewtonsMethodSecondDegree
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br>
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Solves a root of a second degree function with a certain number of iterations.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The found root.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The number of iterations.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/NewtonsMethodSecondDegree.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/NewtonsMethodSecondDegree.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/NewtonsMethodSecondDegree.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="NewtonsMethodSecondDegree" class="js-plotly-plot"></div>
</div>
</section>
<section class="indent">
<h4>
NewtonsMethodThirdDegree
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br>
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Solves a root of a third degree function with a certain number of iterations.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The found root.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The number of iterations.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/NewtonsMethodThirdDegree.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/NewtonsMethodThirdDegree.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/NewtonsMethodThirdDegree.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="NewtonsMethodThirdDegree" class="js-plotly-plot"></div>
</div>
</section>
</div>
</section>
</div>
<div>
<section>
<h3 class="d-flex">
StringBenchmarks
</h3>
<p>
The benchmarks related to this category.
</p>
<div>
<section class="indent">
<h4>
StringConcatenation
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br>
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Concatenates a single character to a string a certain number of times.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The middle character of the concatenated string.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The number of characters to concatenate.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/StringConcatenation.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/StringConcatenation.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/StringConcatenation.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="StringConcatenation">Run the benchmarks to inspect the performance.</div>
</div>
</section>
<section class="indent">
<h4>
StringConcatenationWithBuilder
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br>
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Concatenates a single character to a string a certain number of times using a StringBuilder.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The middle character of the concatenated string.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The number of characters to concatenate.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/StringConcatenationWithBuilder.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/StringConcatenationWithBuilder.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/StringConcatenationWithBuilder.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="StringConcatenationWithBuilder">Run the benchmarks to inspect the performance.</div>
</div>
</section>
</div>
</section>
</div>
<div>
<section>
<h3 class="d-flex">
DictionaryBenchmarks
</h3>
<p>
The benchmarks related to this category.
</p>
<div>
<section class="indent">
<h4>
DictionaryAccessInt
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br> Generates a dictionary of random ints as keys with random ints as values.
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Randomly accesses half of the keys and sums their respective values.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The sum of the values of the accessed keys.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The number of items in the dictionary.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/DictionaryAccessInt.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/DictionaryAccessInt.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/DictionaryAccessInt.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="DictionaryAccessInt" class="js-plotly-plot"></div>
</div>
</section>
<section class="indent">
<h4>
DictionaryAccessString
</h4>
<div class="mb-3">
<strong>Initialization Description</strong>:<br> Generates a dictionary of random strings as keys with random ints as values.
</div>
<div class="mb-3">
<strong>Benchmark Description</strong>:<br> Randomly accesses half of the keys and sums their respective values.
</div>
<div class="mb-3">
<strong>Result Description</strong>:<br> The sum of the values of the accessed keys.
</div>
<div class="mb-3">
<strong>Parameter Description</strong>:<br> The number of items in the dictionary.
</div>
<div class="mb-3">
<strong>Source Code</strong>:<br>
<a href="./Source/Implementations//Benchmarking/Benchmarks/DictionaryAccessString.cs" class="source-code-url-anchor">C#</a>,
<a href="./Source/Implementations//Benchmarking/Benchmarks/DictionaryAccessString.js" class="source-code-url-anchor">JavaScript</a>,
<a href="./Source/Implementations//CWasm/Benchmarks/DictionaryAccessString.c" class="source-code-url-anchor">C</a>
</div>
<div class="mb-3">
<strong>Performance</strong>:
<div id="DictionaryAccessString" class="js-plotly-plot"></div>
</div>
</section>
</div>
</section>
</div>
</div>
</section>
<section id="static-content-helpers" style="display: none;">
<h2>
Static Content Helpers
</h2>
<p>
You can ignore this section. Just some helpers for creating the static website.
</p>
<button onclick="copyHtml()">
Copy HTML
</button>
</section>
<script>
var csRuntimeName = "CS Runtime";
var csWasmAotName = "CS Wasm AOT";
var csWasmInterpretedName = "CS Wasm Interpreted";
var jsName = "JavaScript";
var cWasmName = "C Wasm";
var dataFileUrls = [ "../../Data/ArrayBenchmarks C Wasm (Edge 111.0.1661).json", "../../Data/ArrayBenchmarks CS Runtime.json", "../../Data/ArrayBenchmarks CS Wasm AOT Blazor (Edge 111.0.1661).json", "../../Data/ArrayBenchmarks CS Wasm Interpreted Blazor (Edge 111.0.1661).json", "../../Data/ArrayBenchmarks JavaScript (Edge 111.0.1661).json", "../../Data/DictionaryBenchmarks C Wasm (Edge 111.0.1661).json", "../../Data/DictionaryBenchmarks CS Runtime.json", "../../Data/DictionaryBenchmarks CS Wasm AOT Blazor (Edge 111.0.1661).json", "../../Data/DictionaryBenchmarks CS Wasm Interpreted Blazor (Edge 111.0.1661).json", "../../Data/DictionaryBenchmarks JavaScript (Edge 111.0.1661).json", "../../Data/ListBenchmarks C Wasm (Edge 111.0.1661).json", "../../Data/ListBenchmarks CS Runtime.json", "../../Data/ListBenchmarks CS Wasm AOT Blazor (Edge 111.0.1661).json", "../../Data/ListBenchmarks CS Wasm Interpreted Blazor (Edge 111.0.1661).json", "../../Data/ListBenchmarks JavaScript (Edge 111.0.1661).json", "../../Data/MathBenchmarks C Wasm (Edge 111.0.1661).json", "../../Data/MathBenchmarks CS Runtime.json", "../../Data/MathBenchmarks CS Wasm AOT Blazor (Edge 111.0.1661).json", "../../Data/MathBenchmarks CS Wasm Interpreted Blazor (Edge 111.0.1661).json", "../../Data/MathBenchmarks JavaScript (Edge 111.0.1661).json", "../../Data/StringBenchmarks C Wasm (Edge 111.0.1661).json", "../../Data/StringBenchmarks CS Runtime.json", "../../Data/StringBenchmarks CS Wasm AOT Blazor (Edge 111.0.1661).json", "../../Data/StringBenchmarks CS Wasm Interpreted Blazor (Edge 111.0.1661).json", "../../Data/StringBenchmarks JavaScript (Edge 111.0.1661).json" ];
async function plotData()
{
for (var dfu of dataFileUrls)
{
var url = encodeURI(dfu);
url = url.replace(/#/g, '%23');
var jsonData = await fetch(url).then(response => response.text());
BenchmarkDataPlotter.plotBenchmarkCategoryDataFromJson(jsonData, getLegend(dfu));
}
}
async function fillTable()
{
// Get the ElapsedMilliseconds of all benchmarks and report the relative performance on this page.
var tbody = document.getElementById("conclusions-table-body");
var csRuntimeElapsedMs = [];
var csWasmAotElapsedMs = [];
var csWasmInterpretedElapsedMs = [];
var jsElapsedMs = [];
var cWasmElapsedMs = [];