forked from fastruby/fast-ruby
-
Notifications
You must be signed in to change notification settings - Fork 1
/
truffleruby-3.1.2.fastruby
922 lines (800 loc) · 42 KB
/
truffleruby-3.1.2.fastruby
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
$ ruby -v code/general/array-argument-vs-splat-arguments.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Function with single Array argument
212.654M i/100ms
Function with splat arguments
638.000 i/100ms
Calculating -------------------------------------
Function with single Array argument
2.283B (± 6.1%) i/s - 11.483B in 5.050253s
Function with splat arguments
6.717k (± 6.3%) i/s - 33.814k in 5.055374s
Comparison:
Function with single Array argument: 2282567959.6 i/s
Function with splat arguments: 6717.4 i/s - 339801.55x (± 0.00) slower
$ ruby -v code/general/assignment.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Parallel Assignment 227.298M i/100ms
Sequential Assignment
236.098M i/100ms
Calculating -------------------------------------
Parallel Assignment 2.402B (± 4.7%) i/s - 12.047B in 5.027629s
Sequential Assignment
2.441B (± 4.0%) i/s - 12.277B in 5.038739s
Comparison:
Sequential Assignment: 2440504625.5 i/s
Parallel Assignment: 2401541191.3 i/s - same-ish: difference falls within error
$ ruby -v code/general/attr-accessor-vs-getter-and-setter.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
getter_and_setter 220.494M i/100ms
attr_accessor 217.918M i/100ms
Calculating -------------------------------------
getter_and_setter 2.162B (± 4.6%) i/s - 10.804B in 5.007837s
attr_accessor 2.080B (± 5.4%) i/s - 10.460B in 5.041514s
Comparison:
getter_and_setter: 2161989464.0 i/s
attr_accessor: 2080321620.4 i/s - same-ish: difference falls within error
$ ruby -v code/general/begin-rescue-vs-respond-to.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
begin...rescue 7.482k i/100ms
respond_to? 233.244M i/100ms
Calculating -------------------------------------
begin...rescue 51.935k (± 4.7%) i/s - 261.870k in 5.053651s
respond_to? 2.346B (± 7.0%) i/s - 11.895B in 5.097145s
Comparison:
respond_to?: 2346011757.3 i/s
begin...rescue: 51935.4 i/s - 45171.70x (± 0.00) slower
$ ruby -v code/general/block-apply-method.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
normal 233.224M i/100ms
&method 207.419M i/100ms
Calculating -------------------------------------
normal 2.284B (± 6.8%) i/s - 11.428B in 5.027127s
&method 2.381B (± 6.7%) i/s - 12.030B in 5.078237s
Comparison:
&method: 2380597630.7 i/s
normal: 2283977483.3 i/s - same-ish: difference falls within error
$ ruby -v code/general/define_method-vs-module-eval.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
module_eval with string
96.000 i/100ms
define_method 125.000 i/100ms
Calculating -------------------------------------
module_eval with string
1.680k (±54.5%) i/s - 4.704k in 5.019483s
define_method 3.508k (±59.8%) i/s - 6.000k in 6.368363s
Comparison:
define_method: 3507.9 i/s
module_eval with string: 1679.9 i/s - same-ish: difference falls within error
$ ruby -v code/general/format-vs-round-and-to-s.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Float#round 69.233k i/100ms
Kernel#format 59.932k i/100ms
String#% 62.260k i/100ms
Calculating -------------------------------------
Float#round 725.969k (± 7.2%) i/s - 3.669M in 5.081645s
Kernel#format 641.014k (± 6.5%) i/s - 3.236M in 5.071340s
String#% 618.450k (± 5.7%) i/s - 3.113M in 5.050988s
Comparison:
Float#round: 725969.3 i/s
Kernel#format: 641013.9 i/s - same-ish: difference falls within error
String#%: 618450.3 i/s - 1.17x (± 0.00) slower
$ ruby -v code/general/hash-vs-openstruct-on-access.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash 214.692M i/100ms
OpenStruct 235.095M i/100ms
Calculating -------------------------------------
Hash 2.109B (± 3.7%) i/s - 10.735B in 5.097073s
OpenStruct 2.162B (± 5.8%) i/s - 10.814B in 5.019285s
Comparison:
OpenStruct: 2161740112.8 i/s
Hash: 2108825759.0 i/s - same-ish: difference falls within error
$ ruby -v code/general/hash-vs-openstruct.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash 208.902M i/100ms
OpenStruct 2.494k i/100ms
Calculating -------------------------------------
Hash 2.306B (± 6.8%) i/s - 11.699B in 5.098177s
OpenStruct 27.966k (±12.2%) i/s - 139.664k in 5.107572s
Comparison:
Hash: 2305846365.9 i/s
OpenStruct: 27966.1 i/s - 82451.51x (± 0.00) slower
$ ruby -v code/general/inheritance-check.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
less than or equal 672.398k i/100ms
ancestors.include? 134.517k i/100ms
Calculating -------------------------------------
less than or equal 7.935M (± 8.2%) i/s - 39.671M in 5.034005s
ancestors.include? 1.475M (± 7.9%) i/s - 7.398M in 5.049917s
Comparison:
less than or equal: 7935424.1 i/s
ancestors.include?: 1474534.2 i/s - 5.38x (± 0.00) slower
$ ruby -v code/general/loop-vs-while-true.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
While Loop 1.000 i/100ms
Kernel loop 1.000 i/100ms
Calculating -------------------------------------
While Loop 21.815 (± 4.6%) i/s - 109.000 in 5.016218s
Kernel loop 22.032 (± 9.1%) i/s - 110.000 in 5.015799s
Comparison:
Kernel loop: 22.0 i/s
While Loop: 21.8 i/s - same-ish: difference falls within error
$ ruby -v code/general/raise-vs-e2mmap.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
$ ruby -v code/array/array-first-vs-index.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#[0] 210.826M i/100ms
Array#first 212.540M i/100ms
Calculating -------------------------------------
Array#[0] 2.155B (± 4.7%) i/s - 10.752B in 5.000541s
Array#first 2.112B (± 4.1%) i/s - 10.627B in 5.040750s
Comparison:
Array#[0]: 2154867925.3 i/s
Array#first: 2111633773.1 i/s - same-ish: difference falls within error
$ ruby -v code/array/array-last-vs-index.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#[-1] 213.065M i/100ms
Array#last 209.206M i/100ms
Calculating -------------------------------------
Array#[-1] 2.160B (± 6.2%) i/s - 10.866B in 5.050598s
Array#last 2.143B (± 4.7%) i/s - 10.879B in 5.086974s
Comparison:
Array#[-1]: 2159655009.6 i/s
Array#last: 2143252622.7 i/s - same-ish: difference falls within error
$ ruby -v code/array/bsearch-vs-find.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
find 1.000 i/100ms
bsearch 475.808k i/100ms
Calculating -------------------------------------
find 6.341 (±31.5%) i/s - 13.000 in 5.110710s
bsearch 4.773M (± 5.6%) i/s - 23.790M in 5.000688s
Comparison:
bsearch: 4772549.6 i/s
find: 6.3 i/s - 752690.01x (± 0.00) slower
$ ruby -v code/array/insert-vs-unshift.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#unshift 1.000 i/100ms
Array#insert 1.000 i/100ms
Calculating -------------------------------------
Array#unshift 0.107 (± 0.0%) i/s - 1.000 in 9.330586s
Array#insert 0.856 (± 0.0%) i/s - 5.000 in 5.842984s
Comparison:
Array#insert: 0.9 i/s
Array#unshift: 0.1 i/s - 7.99x (± 0.00) slower
$ ruby -v code/array/length-vs-size-vs-count.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#length 215.030M i/100ms
Array#size 213.723M i/100ms
Array#count 218.968M i/100ms
Calculating -------------------------------------
Array#length 2.168B (± 3.0%) i/s - 10.967B in 5.063414s
Array#size 2.166B (± 3.0%) i/s - 10.900B in 5.037163s
Array#count 2.165B (± 2.8%) i/s - 10.948B in 5.061679s
Comparison:
Array#length: 2167808969.3 i/s
Array#size: 2165911353.4 i/s - same-ish: difference falls within error
Array#count: 2164720645.2 i/s - same-ish: difference falls within error
$ ruby -v code/array/shuffle-first-vs-sample.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#shuffle.first 20.036k i/100ms
Array#sample 2.206M i/100ms
Calculating -------------------------------------
Array#shuffle.first 217.566k (± 3.7%) i/s - 1.102M in 5.072146s
Array#sample 22.664M (± 2.9%) i/s - 114.692M in 5.064667s
Comparison:
Array#sample: 22664278.0 i/s
Array#shuffle.first: 217565.9 i/s - 104.17x (± 0.00) slower
$ ruby -v code/date/iso8601-vs-parse.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Date.iso8601 373.000 i/100ms
Date.parse 298.000 i/100ms
Calculating -------------------------------------
Date.iso8601 34.900k (±32.6%) i/s - 135.026k in 4.991088s
Date.parse 10.784k (±27.9%) i/s - 45.892k in 5.022252s
Comparison:
Date.iso8601: 34900.1 i/s
Date.parse: 10784.3 i/s - 3.24x (± 0.00) slower
$ ruby -v code/enumerable/each-push-vs-map.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#each + push 129.436k i/100ms
Array#map 495.492k i/100ms
Calculating -------------------------------------
Array#each + push 1.451M (± 4.8%) i/s - 7.248M in 5.005659s
Array#map 5.370M (± 6.4%) i/s - 26.757M in 5.003389s
Comparison:
Array#map: 5370320.6 i/s
Array#each + push: 1451477.2 i/s - 3.70x (± 0.00) slower
$ ruby -v code/enumerable/each-vs-for-loop.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
For loop 9.535M i/100ms
#each 50.198M i/100ms
Calculating -------------------------------------
For loop 95.488M (± 3.5%) i/s - 486.281M in 5.099014s
#each 543.216M (± 7.0%) i/s - 2.711B in 5.015253s
Comparison:
#each: 543215540.3 i/s
For loop: 95487698.3 i/s - 5.69x (± 0.00) slower
$ ruby -v code/enumerable/each_with_index-vs-while-loop.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
While Loop 877.711k i/100ms
each_with_index 1.224M i/100ms
Calculating -------------------------------------
While Loop 8.988M (± 5.4%) i/s - 45.641M in 5.093264s
each_with_index 12.811M (± 4.3%) i/s - 64.896M in 5.075644s
Comparison:
each_with_index: 12810890.8 i/s
While Loop: 8988088.9 i/s - 1.43x (± 0.00) slower
$ ruby -v code/enumerable/inject-symbol-vs-block.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
inject symbol 147.741k i/100ms
inject to_proc 140.208k i/100ms
inject block 143.900k i/100ms
Calculating -------------------------------------
inject symbol 1.414M (± 5.4%) i/s - 7.092M in 5.029354s
inject to_proc 1.331M (± 4.8%) i/s - 6.730M in 5.067613s
inject block 1.324M (± 5.2%) i/s - 6.619M in 5.013695s
Comparison:
inject symbol: 1414307.9 i/s
inject to_proc: 1330985.4 i/s - same-ish: difference falls within error
inject block: 1323655.9 i/s - same-ish: difference falls within error
$ ruby -v code/enumerable/map-flatten-vs-flat_map.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#map.flatten(1) 9.336k i/100ms
Array#map.flatten 10.839k i/100ms
Array#flat_map 29.984k i/100ms
Calculating -------------------------------------
Array#map.flatten(1) 112.325k (± 4.7%) i/s - 560.160k in 4.998323s
Array#map.flatten 114.309k (± 4.8%) i/s - 574.467k in 5.037778s
Array#flat_map 307.437k (± 5.0%) i/s - 1.559M in 5.085095s
Comparison:
Array#flat_map: 307436.9 i/s
Array#map.flatten: 114309.3 i/s - 2.69x (± 0.00) slower
Array#map.flatten(1): 112325.3 i/s - 2.74x (± 0.00) slower
$ ruby -v code/enumerable/reverse-each-vs-reverse_each.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#reverse.each 169.186k i/100ms
Array#reverse_each 1.798M i/100ms
Calculating -------------------------------------
Array#reverse.each 1.744M (± 4.2%) i/s - 8.798M in 5.052400s
Array#reverse_each 17.163M (± 2.8%) i/s - 86.313M in 5.032775s
Comparison:
Array#reverse_each: 17163281.2 i/s
Array#reverse.each: 1744345.2 i/s - 9.84x (± 0.00) slower
$ ruby -v code/enumerable/select-first-vs-detect.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#select.first
544.598k i/100ms
Enumerable#detect 3.735M i/100ms
Calculating -------------------------------------
Enumerable#select.first
6.459M (± 6.9%) i/s - 128.525M in 20.023554s
Enumerable#detect 38.313M (± 6.3%) i/s - 765.600M in 20.071041s
Comparison:
Enumerable#detect: 38312661.4 i/s
Enumerable#select.first: 6458508.8 i/s - 5.93x (± 0.00) slower
$ ruby -v code/enumerable/select-last-vs-reverse-detect.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#reverse.detect
177.412k i/100ms
Enumerable#select.last
362.655k i/100ms
Calculating -------------------------------------
Enumerable#reverse.detect
1.767M (± 4.8%) i/s - 8.871M in 5.030382s
Enumerable#select.last
3.723M (± 6.9%) i/s - 18.858M in 5.089274s
Comparison:
Enumerable#select.last: 3723362.6 i/s
Enumerable#reverse.detect: 1767498.3 i/s - 2.11x (± 0.00) slower
$ ruby -v code/enumerable/sort-vs-sort_by.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#sort_by (Symbol#to_proc)
2.026k i/100ms
Enumerable#sort_by 2.331k i/100ms
Enumerable#sort 2.792k i/100ms
Calculating -------------------------------------
Enumerable#sort_by (Symbol#to_proc)
20.886k (±15.6%) i/s - 103.326k in 5.073368s
Enumerable#sort_by 19.534k (±19.8%) i/s - 95.571k in 5.081851s
Enumerable#sort 28.845k (± 7.2%) i/s - 145.184k in 5.059608s
Comparison:
Enumerable#sort: 28845.4 i/s
Enumerable#sort_by (Symbol#to_proc): 20885.5 i/s - 1.38x (± 0.00) slower
Enumerable#sort_by: 19534.0 i/s - 1.48x (± 0.00) slower
$ ruby -v code/enumerable/sort_by-first-vs-min_by.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#min_by 462.861k i/100ms
Enumerable#sort_by...first
5.155k i/100ms
Calculating -------------------------------------
Enumerable#min_by 4.670M (± 5.9%) i/s - 23.606M in 5.073629s
Enumerable#sort_by...first
57.614k (± 4.6%) i/s - 288.680k in 5.021353s
Comparison:
Enumerable#min_by: 4670312.6 i/s
Enumerable#sort_by...first: 57613.9 i/s - 81.06x (± 0.00) slower
$ ruby -v code/hash/bracket-vs-dup.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash[] 179.242k i/100ms
Hash#dup 219.963k i/100ms
Calculating -------------------------------------
Hash[] 2.191M (± 5.4%) i/s - 10.934M in 5.006793s
Hash#dup 2.210M (± 4.4%) i/s - 11.218M in 5.087727s
Comparison:
Hash#dup: 2209553.5 i/s
Hash[]: 2190695.7 i/s - same-ish: difference falls within error
$ ruby -v code/hash/bracket-vs-fetch.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#[], symbol 207.798M i/100ms
Hash#fetch, symbol 220.782M i/100ms
Hash#[], string 2.628M i/100ms
Hash#fetch, string 2.605M i/100ms
Calculating -------------------------------------
Hash#[], symbol 2.201B (± 6.1%) i/s - 11.013B in 5.022668s
Hash#fetch, symbol 2.340B (± 6.1%) i/s - 11.701B in 5.020427s
Hash#[], string 128.026M (± 8.7%) i/s - 635.867M in 5.007287s
Hash#fetch, string 139.095M (± 7.7%) i/s - 693.011M in 5.013298s
Comparison:
Hash#fetch, symbol: 2339924373.0 i/s
Hash#[], symbol: 2200917177.8 i/s - same-ish: difference falls within error
Hash#fetch, string: 139094609.5 i/s - 16.82x (± 0.00) slower
Hash#[], string: 128025661.5 i/s - 18.28x (± 0.00) slower
$ ruby -v code/hash/dig-vs-[]-vs-fetch.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#dig 57.171M i/100ms
Hash#[] 52.812M i/100ms
Hash#[] || 54.322M i/100ms
Hash#[] && 56.862M i/100ms
Hash#fetch 55.907M i/100ms
Hash#fetch fallback 52.128M i/100ms
Calculating -------------------------------------
Hash#dig 520.641M (± 4.5%) i/s - 2.630B in 5.060810s
Hash#[] 530.842M (± 3.8%) i/s - 2.693B in 5.081305s
Hash#[] || 538.914M (± 6.8%) i/s - 2.716B in 5.061036s
Hash#[] && 584.675M (± 3.5%) i/s - 2.957B in 5.063277s
Hash#fetch 585.846M (± 3.8%) i/s - 2.963B in 5.065523s
Hash#fetch fallback 591.802M (± 6.2%) i/s - 2.971B in 5.041341s
Comparison:
Hash#fetch fallback: 591802267.8 i/s
Hash#fetch: 585846416.0 i/s - same-ish: difference falls within error
Hash#[] &&: 584674922.5 i/s - same-ish: difference falls within error
Hash#[] ||: 538913838.3 i/s - same-ish: difference falls within error
Hash#[]: 530841758.0 i/s - 1.11x (± 0.00) slower
Hash#dig: 520640777.9 i/s - 1.14x (± 0.00) slower
$ ruby -v code/hash/fetch-vs-fetch-with-block.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#fetch + const 227.005M i/100ms
Hash#fetch + block 228.050M i/100ms
Hash#fetch + arg 231.592M i/100ms
Calculating -------------------------------------
Hash#fetch + const 2.374B (± 5.8%) i/s - 12.031B in 5.085975s
Hash#fetch + block 2.422B (± 5.7%) i/s - 12.087B in 5.008652s
Hash#fetch + arg 2.316B (± 8.1%) i/s - 11.580B in 5.034428s
Comparison:
Hash#fetch + block: 2421609457.8 i/s
Hash#fetch + const: 2374202125.7 i/s - same-ish: difference falls within error
Hash#fetch + arg: 2316279432.0 i/s - same-ish: difference falls within error
$ ruby -v code/hash/hash-key-sort_by-vs-sort.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
sort_by + to_h 17.440k i/100ms
sort + to_h 6.471k i/100ms
Calculating -------------------------------------
sort_by + to_h 205.725k (± 6.6%) i/s - 1.029M in 5.024791s
sort + to_h 137.988k (± 7.2%) i/s - 685.926k in 4.999483s
Comparison:
sort_by + to_h: 205725.0 i/s
sort + to_h: 137987.8 i/s - 1.49x (± 0.00) slower
$ ruby -v code/hash/keys-each-vs-each_key.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#keys.each 135.466k i/100ms
Hash#each_key 148.322k i/100ms
Calculating -------------------------------------
Hash#keys.each 1.406M (±11.7%) i/s - 6.909M in 5.039282s
Hash#each_key 1.542M (± 5.4%) i/s - 7.713M in 5.016549s
Comparison:
Hash#each_key: 1542109.3 i/s
Hash#keys.each: 1406495.2 i/s - same-ish: difference falls within error
$ ruby -v code/hash/keys-include-vs-key.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#keys.include? 138.000 i/100ms
Hash#key? 11.082M i/100ms
Calculating -------------------------------------
Hash#keys.include? 1.624k (±11.6%) i/s - 8.004k in 5.024617s
Hash#key? 110.513M (± 5.2%) i/s - 554.082M in 5.027673s
Comparison:
Hash#key?: 110512970.4 i/s
Hash#keys.include?: 1624.1 i/s - 68047.39x (± 0.00) slower
$ ruby -v code/hash/merge-bang-vs-[]=.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#merge! 21.748k i/100ms
Hash#[]= 22.148k i/100ms
Calculating -------------------------------------
Hash#merge! 218.696k (±10.1%) i/s - 1.087M in 5.087694s
Hash#[]= 219.108k (± 4.1%) i/s - 1.107M in 5.063053s
Comparison:
Hash#[]=: 219108.0 i/s
Hash#merge!: 218695.8 i/s - same-ish: difference falls within error
$ ruby -v code/hash/merge-bang-vs-merge-vs-dup-merge-bang.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
{}#merge!(Hash) do end
9.904k i/100ms
Hash#merge({}) 7.906k i/100ms
Hash#dup#merge!({}) 13.137k i/100ms
Calculating -------------------------------------
{}#merge!(Hash) do end
125.024k (± 5.6%) i/s - 623.952k in 5.008011s
Hash#merge({}) 82.236k (± 4.5%) i/s - 411.112k in 5.009909s
Hash#dup#merge!({}) 134.717k (± 5.0%) i/s - 683.124k in 5.084308s
Comparison:
Hash#dup#merge!({}): 134717.2 i/s
{}#merge!(Hash) do end: 125024.2 i/s - same-ish: difference falls within error
Hash#merge({}): 82236.0 i/s - 1.64x (± 0.00) slower
$ ruby -v code/hash/merge-vs-double-splat-operator.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#**other 210.729M i/100ms
Hash#merge 207.501M i/100ms
Calculating -------------------------------------
Hash#**other 2.105B (± 4.0%) i/s - 10.536B in 5.012439s
Hash#merge 2.129B (± 4.7%) i/s - 10.790B in 5.080098s
Comparison:
Hash#merge: 2128562978.5 i/s
Hash#**other: 2105339261.2 i/s - same-ish: difference falls within error
$ ruby -v code/hash/merge-vs-merge-bang.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#merge 279.000 i/100ms
Hash#merge! 22.519k i/100ms
Calculating -------------------------------------
Hash#merge 3.410k (± 4.4%) i/s - 17.019k in 5.001319s
Hash#merge! 228.006k (± 3.5%) i/s - 1.148M in 5.043391s
Comparison:
Hash#merge!: 228006.1 i/s
Hash#merge: 3409.8 i/s - 66.87x (± 0.00) slower
$ ruby -v code/hash/slice-native-vs-before-native.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#native-slice 1.052M i/100ms
Array#each 926.214k i/100ms
Array#each_w/_object 951.192k i/100ms
Hash#select-include 1.232M i/100ms
Calculating -------------------------------------
Hash#native-slice 11.433M (± 5.5%) i/s - 57.872M in 5.077592s
Array#each 9.625M (± 5.3%) i/s - 48.163M in 5.018622s
Array#each_w/_object 9.449M (± 3.9%) i/s - 47.560M in 5.041400s
Hash#select-include 13.234M (± 4.7%) i/s - 66.545M in 5.039571s
Comparison:
Hash#select-include : 13234028.8 i/s
Hash#native-slice : 11432770.6 i/s - 1.16x (± 0.00) slower
Array#each : 9625472.7 i/s - 1.37x (± 0.00) slower
Array#each_w/_object: 9448834.6 i/s - 1.40x (± 0.00) slower
$ ruby -v code/hash/values-include-vs-value.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#values.include? 149.000 i/100ms
Hash#value? 365.000 i/100ms
Calculating -------------------------------------
Hash#values.include? 1.737k (±11.9%) i/s - 8.642k in 5.076952s
Hash#value? 3.689k (± 2.1%) i/s - 18.615k in 5.048215s
Comparison:
Hash#value?: 3689.1 i/s
Hash#values.include?: 1736.9 i/s - 2.12x (± 0.00) slower
$ ruby -v code/method/call-vs-send-vs-method_missing.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
call 223.158M i/100ms
send 216.701M i/100ms
method_missing 219.568M i/100ms
Calculating -------------------------------------
call 2.226B (± 3.7%) i/s - 11.158B in 5.018706s
send 2.161B (± 2.9%) i/s - 10.835B in 5.019058s
method_missing 2.160B (± 4.0%) i/s - 10.978B in 5.089804s
Comparison:
call: 2226330426.7 i/s
send: 2160551918.3 i/s - same-ish: difference falls within error
method_missing: 2160295268.3 i/s - same-ish: difference falls within error
$ ruby -v code/proc-and-block/block-vs-to_proc.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Block 14.190k i/100ms
Symbol#to_proc 15.275k i/100ms
Calculating -------------------------------------
Block 153.162k (± 4.9%) i/s - 766.260k in 5.016021s
Symbol#to_proc 154.223k (± 4.5%) i/s - 779.025k in 5.062246s
Comparison:
Symbol#to_proc: 154222.9 i/s
Block: 153162.4 i/s - same-ish: difference falls within error
$ ruby -v code/proc-and-block/proc-call-vs-yield.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
block.call 208.192M i/100ms
block + yield 218.063M i/100ms
unused block 226.841M i/100ms
yield 219.029M i/100ms
Calculating -------------------------------------
block.call 2.172B (± 4.3%) i/s - 11.034B in 5.089633s
block + yield 2.171B (± 3.5%) i/s - 10.903B in 5.029225s
unused block 2.158B (± 2.8%) i/s - 10.888B in 5.049912s
yield 2.147B (± 3.7%) i/s - 10.732B in 5.004824s
Comparison:
block.call: 2172253542.0 i/s
block + yield: 2170761976.0 i/s - same-ish: difference falls within error
unused block: 2157847822.4 i/s - same-ish: difference falls within error
yield: 2147322867.9 i/s - same-ish: difference falls within error
$ ruby -v code/range/cover-vs-include.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
range#cover? 16.699k i/100ms
range#include? 480.000 i/100ms
range#member? 590.000 i/100ms
plain compare 27.596k i/100ms
Calculating -------------------------------------
range#cover? 167.993k (±21.5%) i/s - 801.552k in 5.041389s
range#include? 6.303k (±17.6%) i/s - 30.240k in 5.015675s
range#member? 6.208k (±15.9%) i/s - 29.500k in 5.064855s
plain compare 244.595k (± 6.0%) i/s - 1.242M in 5.095327s
Comparison:
plain compare: 244595.3 i/s
range#cover?: 167992.9 i/s - 1.46x (± 0.00) slower
range#include?: 6303.0 i/s - 38.81x (± 0.00) slower
range#member?: 6207.6 i/s - 39.40x (± 0.00) slower
$ ruby -v code/string/===-vs-=~-vs-match.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#match? 9.378M i/100ms
String#=~ 9.987M i/100ms
Regexp#=== 10.335M i/100ms
String#match 6.821M i/100ms
Calculating -------------------------------------
String#match? 92.615M (± 2.5%) i/s - 468.906M in 5.066216s
String#=~ 100.428M (± 2.0%) i/s - 509.328M in 5.073567s
Regexp#=== 100.008M (± 2.8%) i/s - 506.424M in 5.067678s
String#match 65.136M (± 4.9%) i/s - 327.431M in 5.038786s
Comparison:
String#=~: 100428387.6 i/s
Regexp#===: 100008022.0 i/s - same-ish: difference falls within error
String#match?: 92614926.2 i/s - 1.08x (± 0.00) slower
String#match: 65135800.1 i/s - 1.54x (± 0.00) slower
$ ruby -v code/string/casecmp-vs-downcase-==.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#downcase + == 1.380M i/100ms
String#casecmp 2.569M i/100ms
Calculating -------------------------------------
String#downcase + == 16.007M (± 5.1%) i/s - 80.060M in 5.014995s
String#casecmp 25.555M (± 4.6%) i/s - 128.463M in 5.037664s
Comparison:
String#casecmp: 25555272.7 i/s
String#downcase + ==: 16007352.9 i/s - 1.60x (± 0.00) slower
$ ruby -v code/string/concatenation.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#+ 6.425M i/100ms
String#concat 7.229M i/100ms
String#append 7.283M i/100ms
"foo" "bar" 235.361M i/100ms
"#{'foo'}#{'bar'}" 224.253M i/100ms
Calculating -------------------------------------
String#+ 69.971M (± 5.9%) i/s - 353.399M in 5.068721s
String#concat 71.903M (± 6.6%) i/s - 361.435M in 5.049853s
String#append 70.823M (± 6.5%) i/s - 356.851M in 5.060499s
"foo" "bar" 2.112B (± 6.7%) i/s - 10.591B in 5.037069s
"#{'foo'}#{'bar'}" 2.239B (± 4.9%) i/s - 11.213B in 5.020323s
Comparison:
"#{'foo'}#{'bar'}": 2238957910.3 i/s
"foo" "bar": 2112163501.1 i/s - same-ish: difference falls within error
String#concat: 71902875.9 i/s - 31.14x (± 0.00) slower
String#append: 70823329.9 i/s - 31.61x (± 0.00) slower
String#+: 69971220.5 i/s - 32.00x (± 0.00) slower
$ ruby -v code/string/dup-vs-unary-plus.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#+@ 205.217M i/100ms
String#dup 215.066M i/100ms
Calculating -------------------------------------
String#+@ 2.169B (± 5.6%) i/s - 10.876B in 5.030530s
String#dup 2.222B (± 5.2%) i/s - 11.183B in 5.047138s
Comparison:
String#dup: 2221974707.6 i/s
String#+@: 2168666547.9 i/s - same-ish: difference falls within error
$ ruby -v code/string/end-string-checking-match-vs-end_with.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#=~ 939.424k i/100ms
String#match? 1.089M i/100ms
String#end_with? 7.076M i/100ms
Calculating -------------------------------------
String#=~ 10.080M (± 5.3%) i/s - 50.729M in 5.046927s
String#match? 14.177M (± 3.4%) i/s - 71.896M in 5.077270s
String#end_with? 73.177M (± 3.2%) i/s - 367.948M in 5.033262s
Comparison:
String#end_with?: 73177372.1 i/s
String#match?: 14176526.4 i/s - 5.16x (± 0.00) slower
String#=~: 10079995.0 i/s - 7.26x (± 0.00) slower
$ ruby -v code/string/gsub-vs-sub.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#gsub 118.173k i/100ms
String#sub 288.210k i/100ms
String#dup["string"]=
9.446M i/100ms
Calculating -------------------------------------
String#gsub 3.442M (±10.6%) i/s - 17.017M in 5.017007s
String#sub 4.624M (± 9.3%) i/s - 23.057M in 5.036480s
String#dup["string"]=
92.403M (± 4.4%) i/s - 462.862M in 5.018971s
Comparison:
String#dup["string"]=: 92403432.9 i/s
String#sub: 4623852.8 i/s - 19.98x (± 0.00) slower
String#gsub: 3441661.4 i/s - 26.85x (± 0.00) slower
$ ruby -v code/string/gsub-vs-tr.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#gsub 49.059k i/100ms
String#tr 85.310k i/100ms
Calculating -------------------------------------
String#gsub 1.650M (± 8.2%) i/s - 8.193M in 5.006796s
String#tr 854.182k (± 5.0%) i/s - 4.266M in 5.006679s
Comparison:
String#gsub: 1649882.4 i/s
String#tr: 854181.7 i/s - 1.93x (± 0.00) slower
$ ruby -v code/string/mutable_vs_immutable_strings.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Without Freeze 207.967M i/100ms
With Freeze 212.927M i/100ms
Calculating -------------------------------------
Without Freeze 2.153B (± 5.2%) i/s - 10.814B in 5.035773s
With Freeze 2.169B (± 3.6%) i/s - 10.859B in 5.013791s
Comparison:
With Freeze: 2168849264.5 i/s
Without Freeze: 2153114112.5 i/s - same-ish: difference falls within error
$ ruby -v code/string/remove-extra-spaces-or-other-chars.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#gsub/regex+/ 4.538k i/100ms
String#squeeze 24.988k i/100ms
Calculating -------------------------------------
String#gsub/regex+/ 57.162k (± 5.7%) i/s - 285.894k in 5.018629s
String#squeeze 251.843k (± 4.3%) i/s - 1.274M in 5.069614s
Comparison:
String#squeeze: 251843.4 i/s
String#gsub/regex+/: 57161.8 i/s - 4.41x (± 0.00) slower
$ ruby -v code/string/start-string-checking-match-vs-start_with.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#=~ 1.957M i/100ms
String#match? 3.419M i/100ms
String#start_with? 13.527M i/100ms
Calculating -------------------------------------
String#=~ 21.948M (± 5.5%) i/s - 109.583M in 5.008709s
String#match? 33.753M (± 4.6%) i/s - 170.965M in 5.075902s
String#start_with? 135.218M (± 4.3%) i/s - 676.359M in 5.011182s
Comparison:
String#start_with?: 135218111.9 i/s
String#match?: 33752994.3 i/s - 4.01x (± 0.00) slower
String#=~: 21947502.5 i/s - 6.16x (± 0.00) slower
$ ruby -v code/string/start_with-vs-substring-==.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#start_with? 85.155k i/100ms
String#[0, n] == 186.681k i/100ms
String#[RANGE] == 268.740k i/100ms
String#[0...n] == 157.925k i/100ms
Calculating -------------------------------------
String#start_with? 3.903M (± 6.2%) i/s - 19.500M in 5.014846s
String#[0, n] == 1.943M (± 5.4%) i/s - 9.707M in 5.010810s
String#[RANGE] == 2.684M (± 4.3%) i/s - 13.437M in 5.015198s
String#[0...n] == 1.671M (± 4.1%) i/s - 8.370M in 5.018529s
Comparison:
String#start_with?: 3903185.0 i/s
String#[RANGE] ==: 2684341.7 i/s - 1.45x (± 0.00) slower
String#[0, n] ==: 1943375.5 i/s - 2.01x (± 0.00) slower
String#[0...n] ==: 1670737.6 i/s - 2.34x (± 0.00) slower
$ ruby -v code/string/sub!-vs-gsub!-vs-[]=.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#['string']= 9.234M i/100ms
String#sub!'string' 293.614k i/100ms
String#gsub!'string' 376.108k i/100ms
String#[/regexp/]= 1.260M i/100ms
String#sub!/regexp/ 1.330M i/100ms
String#gsub!/regexp/ 387.761k i/100ms
Calculating -------------------------------------
String#['string']= 92.209M (± 2.9%) i/s - 461.702M in 5.011486s
String#sub!'string' 4.961M (±18.8%) i/s - 22.021M in 5.007579s
String#gsub!'string' 3.684M (± 4.5%) i/s - 18.429M in 5.013166s
String#[/regexp/]= 13.124M (± 3.4%) i/s - 65.534M in 4.999526s
String#sub!/regexp/ 13.872M (± 5.5%) i/s - 69.185M in 5.002581s
String#gsub!/regexp/ 3.893M (± 6.2%) i/s - 19.388M in 5.000068s
Comparison:
String#['string']=: 92208991.2 i/s
String#sub!/regexp/: 13871935.7 i/s - 6.65x (± 0.00) slower
String#[/regexp/]=: 13124296.5 i/s - 7.03x (± 0.00) slower
String#sub!'string': 4960590.2 i/s - 18.59x (± 0.00) slower
String#gsub!/regexp/: 3892667.7 i/s - 23.69x (± 0.00) slower
String#gsub!'string': 3684053.6 i/s - 25.03x (± 0.00) slower
$ ruby -v code/string/sub-vs-chomp-vs-delete_suffix.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#sub 1.482M i/100ms
String#chomp 3.373M i/100ms
String#delete_suffix 4.249M i/100ms
Calculating -------------------------------------
String#sub 15.828M (± 4.4%) i/s - 80.009M in 5.065103s
String#chomp 32.774M (± 2.5%) i/s - 165.295M in 5.046638s
String#delete_suffix 43.793M (± 4.8%) i/s - 220.942M in 5.056814s
Comparison:
String#delete_suffix: 43793099.3 i/s
String#chomp: 32773929.6 i/s - 1.34x (± 0.00) slower
String#sub: 15827940.8 i/s - 2.77x (± 0.00) slower
$ ruby -v code/string/sub-vs-delete_prefix.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#delete_prefix 202.190M i/100ms
String#sub 10.370M i/100ms
Calculating -------------------------------------
String#delete_prefix 2.251B (± 5.6%) i/s - 11.323B in 5.045238s
String#sub 109.870M (± 5.3%) i/s - 549.602M in 5.016773s
Comparison:
String#delete_prefix: 2251192097.4 i/s
String#sub: 109870441.2 i/s - 20.49x (± 0.00) slower
$ ruby -v code/string/unpack1-vs-unpack[0].rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#unpack1 1.163M i/100ms
String#unpack[0] 1.316M i/100ms
Calculating -------------------------------------
String#unpack1 13.762M (± 6.3%) i/s - 68.612M in 5.006323s
String#unpack[0] 13.590M (± 6.1%) i/s - 68.417M in 5.053492s
Comparison:
String#unpack1: 13762108.9 i/s
String#unpack[0]: 13590329.9 i/s - same-ish: difference falls within error
$ ruby -v code/time/iso8601-vs-parse.rb
truffleruby 23.0.0-dev-68a36488, like ruby 3.1.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Time.iso8601 17.802k i/100ms
Time.parse 193.000 i/100ms
Calculating -------------------------------------
Time.iso8601 247.570k (± 8.9%) i/s - 1.228M in 4.999254s
Time.parse 6.822k (±27.4%) i/s - 27.985k in 5.005289s
Comparison:
Time.iso8601: 247569.8 i/s
Time.parse: 6822.1 i/s - 36.29x (± 0.00) slower