forked from fastruby/fast-ruby
-
Notifications
You must be signed in to change notification settings - Fork 1
/
truffleruby-3.2.4.fastruby
922 lines (800 loc) · 42 KB
/
truffleruby-3.2.4.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 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Function with single Array argument
310.703M i/100ms
Function with splat arguments
1.851k i/100ms
Calculating -------------------------------------
Function with single Array argument
3.118B (± 2.9%) i/s - 15.846B in 5.086929s
Function with splat arguments
20.450k (± 8.6%) i/s - 101.805k in 5.026099s
Comparison:
Function with single Array argument: 3117803313.9 i/s
Function with splat arguments: 20449.9 i/s - 152460.46x (± 0.00) slower
$ ruby -v code/general/assignment.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Parallel Assignment 310.581M i/100ms
Sequential Assignment
302.893M i/100ms
Calculating -------------------------------------
Parallel Assignment 3.156B (± 2.9%) i/s - 15.840B in 5.023540s
Sequential Assignment
3.140B (± 2.7%) i/s - 15.750B in 5.019633s
Comparison:
Parallel Assignment: 3155879707.4 i/s
Sequential Assignment: 3140098501.2 i/s - same-ish: difference falls within error
$ ruby -v code/general/attr-accessor-vs-getter-and-setter.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
getter_and_setter 319.554M i/100ms
attr_accessor 319.680M i/100ms
Calculating -------------------------------------
getter_and_setter 3.159B (± 2.8%) i/s - 15.978B in 5.062723s
attr_accessor 3.077B (± 3.8%) i/s - 15.664B in 5.098631s
Comparison:
getter_and_setter: 3158604954.8 i/s
attr_accessor: 3076824958.5 i/s - same-ish: difference falls within error
$ ruby -v code/general/begin-rescue-vs-respond-to.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
begin...rescue 8.691k i/100ms
respond_to? 309.257M i/100ms
Calculating -------------------------------------
begin...rescue 102.791k (± 7.8%) i/s - 512.769k in 5.040090s
respond_to? 3.137B (± 3.9%) i/s - 15.772B in 5.035975s
Comparison:
respond_to?: 3136937961.9 i/s
begin...rescue: 102791.0 i/s - 30517.63x (± 0.00) slower
$ ruby -v code/general/block-apply-method.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
normal 318.736M i/100ms
&method 18.216M i/100ms
Calculating -------------------------------------
normal 3.164B (± 3.0%) i/s - 15.937B in 5.042178s
&method 176.599M (± 1.8%) i/s - 892.565M in 5.055915s
Comparison:
normal: 3163808515.1 i/s
&method: 176598691.4 i/s - 17.92x (± 0.00) slower
$ ruby -v code/general/define_method-vs-module-eval.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
module_eval with string
166.000 i/100ms
define_method 145.000 i/100ms
Calculating -------------------------------------
module_eval with string
3.538k (±57.8%) i/s - 7.636k in 6.850724s
define_method 11.658k (±40.9%) i/s - 9.860k in 6.749536s
Comparison:
define_method: 11658.4 i/s
module_eval with string: 3538.3 i/s - 3.29x (± 0.00) slower
$ ruby -v code/general/format-vs-round-and-to-s.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Float#round 270.387k i/100ms
Kernel#format 177.732k i/100ms
String#% 108.642k i/100ms
Calculating -------------------------------------
Float#round 2.610M (± 6.7%) i/s - 12.979M in 5.007181s
Kernel#format 1.747M (± 6.2%) i/s - 8.709M in 5.015462s
String#% 1.070M (± 3.6%) i/s - 5.432M in 5.082788s
Comparison:
Float#round: 2610215.9 i/s
Kernel#format: 1746768.4 i/s - 1.49x (± 0.00) slower
String#%: 1070285.9 i/s - 2.44x (± 0.00) slower
$ ruby -v code/general/hash-vs-openstruct-on-access.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash 322.239M i/100ms
OpenStruct 322.262M i/100ms
Calculating -------------------------------------
Hash 3.193B (± 3.6%) i/s - 16.112B in 5.053782s
OpenStruct 3.217B (± 0.5%) i/s - 16.113B in 5.009436s
Comparison:
OpenStruct: 3216641936.3 i/s
Hash: 3193141291.7 i/s - same-ish: difference falls within error
$ ruby -v code/general/hash-vs-openstruct.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash 320.320M i/100ms
OpenStruct 2.689k i/100ms
Calculating -------------------------------------
Hash 3.139B (± 8.0%) i/s - 15.696B in 5.050982s
OpenStruct 36.293k (±31.5%) i/s - 164.029k in 5.023810s
Comparison:
Hash: 3138713159.1 i/s
OpenStruct: 36293.2 i/s - 86482.03x (± 0.00) slower
$ ruby -v code/general/inheritance-check.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
less than or equal 890.449k i/100ms
ancestors.include? 217.891k i/100ms
Calculating -------------------------------------
less than or equal 10.142M (± 4.8%) i/s - 50.756M in 5.016616s
ancestors.include? 2.310M (± 5.3%) i/s - 11.548M in 5.014278s
Comparison:
less than or equal: 10142326.6 i/s
ancestors.include?: 2310389.8 i/s - 4.39x (± 0.00) slower
$ ruby -v code/general/loop-vs-while-true.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
While Loop 1.000 i/100ms
Kernel loop 1.000 i/100ms
Calculating -------------------------------------
While Loop 32.050 (± 3.1%) i/s - 160.000 in 5.000779s
Kernel loop 31.917 (± 6.3%) i/s - 160.000 in 5.028072s
Comparison:
While Loop: 32.1 i/s
Kernel loop: 31.9 i/s - same-ish: difference falls within error
$ ruby -v code/general/raise-vs-e2mmap.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
$ ruby -v code/array/array-first-vs-index.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#[0] 322.782M i/100ms
Array#first 318.074M i/100ms
Calculating -------------------------------------
Array#[0] 3.187B (± 2.8%) i/s - 16.139B in 5.067750s
Array#first 3.208B (± 1.9%) i/s - 16.222B in 5.059024s
Comparison:
Array#first: 3207728525.6 i/s
Array#[0]: 3187360082.9 i/s - same-ish: difference falls within error
$ ruby -v code/array/array-last-vs-index.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#[-1] 321.939M i/100ms
Array#last 322.126M i/100ms
Calculating -------------------------------------
Array#[-1] 3.196B (± 2.6%) i/s - 16.097B in 5.040674s
Array#last 3.197B (± 2.5%) i/s - 16.106B in 5.041032s
Comparison:
Array#last: 3197149440.7 i/s
Array#[-1]: 3195755532.1 i/s - same-ish: difference falls within error
$ ruby -v code/array/bsearch-vs-find.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
find 1.000 i/100ms
bsearch 910.292k i/100ms
Calculating -------------------------------------
find 13.722 (± 0.0%) i/s - 69.000 in 5.032245s
bsearch 9.206M (± 3.0%) i/s - 46.425M in 5.047930s
Comparison:
bsearch: 9205619.5 i/s
find: 13.7 i/s - 670883.64x (± 0.00) slower
$ ruby -v code/array/insert-vs-unshift.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#unshift 1.000 i/100ms
Array#insert 1.000 i/100ms
Calculating -------------------------------------
Array#unshift 0.212 (± 0.0%) i/s - 2.000 in 9.455862s
Array#insert 1.392 (± 0.0%) i/s - 7.000 in 5.031354s
Comparison:
Array#insert: 1.4 i/s
Array#unshift: 0.2 i/s - 6.58x (± 0.00) slower
$ ruby -v code/array/length-vs-size-vs-count.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#length 320.712M i/100ms
Array#size 320.976M i/100ms
Array#count 313.318M i/100ms
Calculating -------------------------------------
Array#length 3.210B (± 1.7%) i/s - 16.356B in 5.097658s
Array#size 3.217B (± 2.0%) i/s - 16.370B in 5.091354s
Array#count 3.192B (± 3.7%) i/s - 15.979B in 5.014331s
Comparison:
Array#size: 3216650969.1 i/s
Array#length: 3209595908.4 i/s - same-ish: difference falls within error
Array#count: 3191802815.4 i/s - same-ish: difference falls within error
$ ruby -v code/array/shuffle-first-vs-sample.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#shuffle.first 35.975k i/100ms
Array#sample 3.798M i/100ms
Calculating -------------------------------------
Array#shuffle.first 366.951k (± 3.0%) i/s - 1.835M in 5.004848s
Array#sample 37.625M (± 0.9%) i/s - 189.915M in 5.048087s
Comparison:
Array#sample: 37624504.0 i/s
Array#shuffle.first: 366950.9 i/s - 102.53x (± 0.00) slower
$ ruby -v code/date/iso8601-vs-parse.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Date.iso8601 850.000 i/100ms
Date.parse 552.000 i/100ms
Calculating -------------------------------------
Date.iso8601 15.520k (±27.5%) i/s - 72.250k in 5.034911s
Date.parse 7.867k (±20.2%) i/s - 37.536k in 5.024933s
Comparison:
Date.iso8601: 15520.5 i/s
Date.parse: 7866.5 i/s - 1.97x (± 0.00) slower
$ ruby -v code/enumerable/each-push-vs-map.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#each + push 295.010k i/100ms
Array#map 1.843M i/100ms
Calculating -------------------------------------
Array#each + push 3.299M (± 7.0%) i/s - 16.521M in 5.034131s
Array#map 19.858M (± 6.8%) i/s - 99.521M in 5.035623s
Comparison:
Array#map: 19857989.3 i/s
Array#each + push: 3298833.2 i/s - 6.02x (± 0.00) slower
$ ruby -v code/enumerable/each-vs-for-loop.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
For loop 11.765M i/100ms
#each 34.460M i/100ms
Calculating -------------------------------------
For loop 117.988M (± 2.1%) i/s - 600.040M in 5.088082s
#each 348.614M (± 2.0%) i/s - 1.757B in 5.043353s
Comparison:
#each: 348613806.8 i/s
For loop: 117988073.4 i/s - 2.95x (± 0.00) slower
$ ruby -v code/enumerable/each_with_index-vs-while-loop.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
While Loop 1.400M i/100ms
each_with_index 2.338M i/100ms
Calculating -------------------------------------
While Loop 14.396M (± 4.0%) i/s - 72.782M in 5.064176s
each_with_index 23.296M (± 2.8%) i/s - 116.899M in 5.021976s
Comparison:
each_with_index: 23295611.2 i/s
While Loop: 14395615.3 i/s - 1.62x (± 0.00) slower
$ ruby -v code/enumerable/inject-symbol-vs-block.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
inject symbol 304.997k i/100ms
inject to_proc 312.908k i/100ms
inject block 312.608k i/100ms
Calculating -------------------------------------
inject symbol 3.097M (± 2.8%) i/s - 15.555M in 5.026802s
inject to_proc 3.102M (± 1.8%) i/s - 15.645M in 5.044533s
inject block 3.099M (± 4.3%) i/s - 15.630M in 5.056018s
Comparison:
inject to_proc: 3102473.0 i/s
inject block: 3099260.1 i/s - same-ish: difference falls within error
inject symbol: 3096963.3 i/s - same-ish: difference falls within error
$ ruby -v code/enumerable/map-flatten-vs-flat_map.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#map.flatten(1) 21.346k i/100ms
Array#map.flatten 23.453k i/100ms
Array#flat_map 55.765k i/100ms
Calculating -------------------------------------
Array#map.flatten(1) 266.561k (± 5.1%) i/s - 1.345M in 5.058749s
Array#map.flatten 270.057k (± 7.0%) i/s - 1.360M in 5.062497s
Array#flat_map 575.008k (± 3.7%) i/s - 2.900M in 5.050767s
Comparison:
Array#flat_map: 575007.5 i/s
Array#map.flatten: 270056.6 i/s - 2.13x (± 0.00) slower
Array#map.flatten(1): 266561.3 i/s - 2.16x (± 0.00) slower
$ ruby -v code/enumerable/reverse-each-vs-reverse_each.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#reverse.each 330.033k i/100ms
Array#reverse_each 2.359M i/100ms
Calculating -------------------------------------
Array#reverse.each 3.391M (± 7.0%) i/s - 16.832M in 5.000328s
Array#reverse_each 23.844M (± 2.3%) i/s - 120.333M in 5.049215s
Comparison:
Array#reverse_each: 23844479.3 i/s
Array#reverse.each: 3390594.4 i/s - 7.03x (± 0.00) slower
$ ruby -v code/enumerable/select-first-vs-detect.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#select.first
802.228k i/100ms
Enumerable#detect 4.685M i/100ms
Calculating -------------------------------------
Enumerable#select.first
10.247M (± 8.1%) i/s - 202.964M in 20.000971s
Enumerable#detect 46.610M (± 2.3%) i/s - 932.232M in 20.012307s
Comparison:
Enumerable#detect: 46609912.3 i/s
Enumerable#select.first: 10246744.9 i/s - 4.55x (± 0.00) slower
$ ruby -v code/enumerable/select-last-vs-reverse-detect.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#reverse.detect
327.783k i/100ms
Enumerable#select.last
553.308k i/100ms
Calculating -------------------------------------
Enumerable#reverse.detect
3.490M (± 5.3%) i/s - 17.700M in 5.086580s
Enumerable#select.last
5.562M (± 3.1%) i/s - 28.219M in 5.078712s
Comparison:
Enumerable#select.last: 5562042.9 i/s
Enumerable#reverse.detect: 3489991.1 i/s - 1.59x (± 0.00) slower
$ ruby -v code/enumerable/sort-vs-sort_by.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#sort_by (Symbol#to_proc)
2.920k i/100ms
Enumerable#sort_by 4.079k i/100ms
Enumerable#sort 5.056k i/100ms
Calculating -------------------------------------
Enumerable#sort_by (Symbol#to_proc)
34.090k (±21.1%) i/s - 160.600k in 5.020237s
Enumerable#sort_by 41.466k (±11.4%) i/s - 203.950k in 5.028906s
Enumerable#sort 55.122k (± 4.0%) i/s - 278.080k in 5.053767s
Comparison:
Enumerable#sort: 55121.6 i/s
Enumerable#sort_by: 41465.6 i/s - 1.33x (± 0.00) slower
Enumerable#sort_by (Symbol#to_proc): 34089.5 i/s - 1.62x (± 0.00) slower
$ ruby -v code/enumerable/sort_by-first-vs-min_by.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#min_by 925.721k i/100ms
Enumerable#sort_by...first
8.792k i/100ms
Calculating -------------------------------------
Enumerable#min_by 9.353M (± 1.8%) i/s - 47.212M in 5.049544s
Enumerable#sort_by...first
109.771k (± 4.3%) i/s - 553.896k in 5.055462s
Comparison:
Enumerable#min_by: 9352546.0 i/s
Enumerable#sort_by...first: 109771.2 i/s - 85.20x (± 0.00) slower
$ ruby -v code/hash/bracket-vs-dup.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash[] 629.410k i/100ms
Hash#dup 749.145k i/100ms
Calculating -------------------------------------
Hash[] 7.669M (±10.3%) i/s - 38.394M in 5.088335s
Hash#dup 7.549M (±10.1%) i/s - 37.457M in 5.022582s
Comparison:
Hash[]: 7668978.8 i/s
Hash#dup: 7549142.5 i/s - same-ish: difference falls within error
$ ruby -v code/hash/bracket-vs-fetch.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#[], symbol 320.997M i/100ms
Hash#fetch, symbol 320.198M i/100ms
Hash#[], string 32.304M i/100ms
Hash#fetch, string 26.626M i/100ms
Calculating -------------------------------------
Hash#[], symbol 3.120B (± 2.0%) i/s - 15.729B in 5.043895s
Hash#fetch, symbol 3.163B (± 3.1%) i/s - 16.010B in 5.067494s
Hash#[], string 321.479M (± 1.7%) i/s - 1.615B in 5.025906s
Hash#fetch, string 265.606M (± 3.6%) i/s - 1.331B in 5.019484s
Comparison:
Hash#fetch, symbol: 3162714659.6 i/s
Hash#[], symbol: 3119630549.7 i/s - same-ish: difference falls within error
Hash#[], string: 321478717.8 i/s - 9.84x (± 0.00) slower
Hash#fetch, string: 265605548.0 i/s - 11.91x (± 0.00) slower
$ ruby -v code/hash/dig-vs-[]-vs-fetch.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#dig 91.268M i/100ms
Hash#[] 91.475M i/100ms
Hash#[] || 92.340M i/100ms
Hash#[] && 92.355M i/100ms
Hash#fetch 92.349M i/100ms
Hash#fetch fallback 92.191M i/100ms
Calculating -------------------------------------
Hash#dig 914.413M (± 2.5%) i/s - 4.655B in 5.093790s
Hash#[] 918.729M (± 1.8%) i/s - 4.665B in 5.079644s
Hash#[] || 915.871M (± 2.1%) i/s - 4.617B in 5.043481s
Hash#[] && 910.111M (± 3.2%) i/s - 4.618B in 5.079434s
Hash#fetch 915.172M (± 2.1%) i/s - 4.617B in 5.047851s
Hash#fetch fallback 915.807M (± 2.6%) i/s - 4.610B in 5.037079s
Comparison:
Hash#[]: 918729101.8 i/s
Hash#[] ||: 915870631.9 i/s - same-ish: difference falls within error
Hash#fetch fallback: 915807399.4 i/s - same-ish: difference falls within error
Hash#fetch: 915171563.7 i/s - same-ish: difference falls within error
Hash#dig: 914413391.7 i/s - same-ish: difference falls within error
Hash#[] &&: 910110621.4 i/s - same-ish: difference falls within error
$ ruby -v code/hash/fetch-vs-fetch-with-block.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#fetch + const 319.937M i/100ms
Hash#fetch + block 296.594M i/100ms
Hash#fetch + arg 311.786M i/100ms
Calculating -------------------------------------
Hash#fetch + const 3.148B (± 2.6%) i/s - 15.997B in 5.084849s
Hash#fetch + block 3.150B (± 3.0%) i/s - 16.016B in 5.090073s
Hash#fetch + arg 3.131B (± 3.4%) i/s - 15.901B in 5.084670s
Comparison:
Hash#fetch + block: 3149628215.0 i/s
Hash#fetch + const: 3148295161.6 i/s - same-ish: difference falls within error
Hash#fetch + arg: 3131133392.1 i/s - same-ish: difference falls within error
$ ruby -v code/hash/hash-key-sort_by-vs-sort.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
sort_by + to_h 38.886k i/100ms
sort + to_h 6.388k i/100ms
Calculating -------------------------------------
sort_by + to_h 541.762k (± 7.4%) i/s - 2.722M in 5.066495s
sort + to_h 219.901k (±12.2%) i/s - 1.080M in 5.024050s
Comparison:
sort_by + to_h: 541762.1 i/s
sort + to_h: 219900.6 i/s - 2.46x (± 0.00) slower
$ ruby -v code/hash/keys-each-vs-each_key.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#keys.each 205.846k i/100ms
Hash#each_key 204.527k i/100ms
Calculating -------------------------------------
Hash#keys.each 2.070M (± 9.3%) i/s - 10.292M in 5.065291s
Hash#each_key 2.208M (± 4.0%) i/s - 11.044M in 5.011969s
Comparison:
Hash#each_key: 2207821.8 i/s
Hash#keys.each: 2069738.1 i/s - same-ish: difference falls within error
$ ruby -v code/hash/keys-include-vs-key.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#keys.include? 292.000 i/100ms
Hash#key? 15.740M i/100ms
Calculating -------------------------------------
Hash#keys.include? 3.127k (±15.2%) i/s - 15.184k in 5.003207s
Hash#key? 157.161M (± 1.5%) i/s - 787.003M in 5.008889s
Comparison:
Hash#key?: 157161184.8 i/s
Hash#keys.include?: 3127.5 i/s - 50251.83x (± 0.00) slower
$ ruby -v code/hash/merge-bang-vs-[]=.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#merge! 53.405k i/100ms
Hash#[]= 58.909k i/100ms
Calculating -------------------------------------
Hash#merge! 569.352k (± 8.1%) i/s - 2.830M in 5.017591s
Hash#[]= 617.150k (± 8.2%) i/s - 3.063M in 5.010713s
Comparison:
Hash#[]=: 617149.7 i/s
Hash#merge!: 569352.3 i/s - same-ish: difference falls within error
$ ruby -v code/hash/merge-bang-vs-merge-vs-dup-merge-bang.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
{}#merge!(Hash) do end
31.598k i/100ms
Hash#merge({}) 19.432k i/100ms
Hash#dup#merge!({}) 30.167k i/100ms
Calculating -------------------------------------
{}#merge!(Hash) do end
397.264k (±11.7%) i/s - 1.959M in 5.008402s
Hash#merge({}) 195.922k (±11.0%) i/s - 971.600k in 5.025633s
Hash#dup#merge!({}) 324.166k (± 5.8%) i/s - 1.629M in 5.044216s
Comparison:
{}#merge!(Hash) do end: 397263.8 i/s
Hash#dup#merge!({}): 324166.3 i/s - 1.23x (± 0.00) slower
Hash#merge({}): 195922.5 i/s - 2.03x (± 0.00) slower
$ ruby -v code/hash/merge-vs-double-splat-operator.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#**other 322.770M i/100ms
Hash#merge 306.586M i/100ms
Calculating -------------------------------------
Hash#**other 3.169B (± 4.0%) i/s - 15.816B in 4.999967s
Hash#merge 3.129B (± 3.9%) i/s - 15.636B in 5.005191s
Comparison:
Hash#**other: 3168971730.1 i/s
Hash#merge: 3129124655.8 i/s - same-ish: difference falls within error
$ ruby -v code/hash/merge-vs-merge-bang.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#merge 946.000 i/100ms
Hash#merge! 58.626k i/100ms
Calculating -------------------------------------
Hash#merge 12.495k (±11.4%) i/s - 61.490k in 5.004371s
Hash#merge! 594.948k (± 3.4%) i/s - 2.990M in 5.031506s
Comparison:
Hash#merge!: 594947.9 i/s
Hash#merge: 12495.0 i/s - 47.61x (± 0.00) slower
$ ruby -v code/hash/slice-native-vs-before-native.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#native-slice 1.451M i/100ms
Array#each 1.487M i/100ms
Array#each_w/_object 1.427M i/100ms
Hash#select-include 2.394M i/100ms
Calculating -------------------------------------
Hash#native-slice 18.941M (± 8.0%) i/s - 94.332M in 5.031312s
Array#each 16.107M (± 4.1%) i/s - 81.812M in 5.089256s
Array#each_w/_object 14.913M (± 4.7%) i/s - 75.652M in 5.085059s
Hash#select-include 24.540M (± 4.0%) i/s - 124.486M in 5.081339s
Comparison:
Hash#select-include : 24540107.4 i/s
Hash#native-slice : 18940588.1 i/s - 1.30x (± 0.00) slower
Array#each : 16106829.6 i/s - 1.52x (± 0.00) slower
Array#each_w/_object: 14912903.5 i/s - 1.65x (± 0.00) slower
$ ruby -v code/hash/values-include-vs-value.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#values.include? 231.000 i/100ms
Hash#value? 652.000 i/100ms
Calculating -------------------------------------
Hash#values.include? 3.099k (±12.0%) i/s - 15.246k in 5.033767s
Hash#value? 6.640k (± 0.7%) i/s - 33.252k in 5.008016s
Comparison:
Hash#value?: 6640.1 i/s
Hash#values.include?: 3099.5 i/s - 2.14x (± 0.00) slower
$ ruby -v code/method/call-vs-send-vs-method_missing.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
call 321.564M i/100ms
send 285.292M i/100ms
method_missing 322.260M i/100ms
Calculating -------------------------------------
call 3.213B (± 1.1%) i/s - 16.078B in 5.004323s
send 3.195B (± 3.2%) i/s - 15.976B in 5.005907s
method_missing 3.210B (± 1.5%) i/s - 16.113B in 5.020533s
Comparison:
call: 3213258245.9 i/s
method_missing: 3210177319.6 i/s - same-ish: difference falls within error
send: 3195145945.2 i/s - same-ish: difference falls within error
$ ruby -v code/proc-and-block/block-vs-to_proc.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Block 56.453k i/100ms
Symbol#to_proc 63.706k i/100ms
Calculating -------------------------------------
Block 741.205k (±16.7%) i/s - 3.613M in 5.041110s
Symbol#to_proc 772.034k (±15.4%) i/s - 3.759M in 5.002692s
Comparison:
Symbol#to_proc: 772033.5 i/s
Block: 741205.4 i/s - same-ish: difference falls within error
$ ruby -v code/proc-and-block/proc-call-vs-yield.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
block.call 321.805M i/100ms
block + yield 322.573M i/100ms
unused block 322.996M i/100ms
yield 322.902M i/100ms
Calculating -------------------------------------
block.call 3.207B (± 1.9%) i/s - 16.090B in 5.018776s
block + yield 3.201B (± 2.7%) i/s - 16.129B in 5.042818s
unused block 3.212B (± 1.6%) i/s - 16.150B in 5.029499s
yield 3.202B (± 2.7%) i/s - 16.145B in 5.046300s
Comparison:
unused block: 3211864640.8 i/s
block.call: 3207227071.1 i/s - same-ish: difference falls within error
yield: 3201938401.0 i/s - same-ish: difference falls within error
block + yield: 3200835208.7 i/s - same-ish: difference falls within error
$ ruby -v code/range/cover-vs-include.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
range#cover? 5.060k i/100ms
range#include? 187.000 i/100ms
range#member? 221.000 i/100ms
plain compare 7.791k i/100ms
Calculating -------------------------------------
range#cover? 64.153k (±33.6%) i/s - 273.240k in 5.101616s
range#include? 3.145k (±40.7%) i/s - 12.342k in 5.030251s
range#member? 2.589k (±32.9%) i/s - 11.492k in 5.063441s
plain compare 91.862k (±30.2%) i/s - 405.132k in 5.018993s
Comparison:
plain compare: 91862.3 i/s
range#cover?: 64152.9 i/s - same-ish: difference falls within error
range#include?: 3145.0 i/s - 29.21x (± 0.00) slower
range#member?: 2589.4 i/s - 35.48x (± 0.00) slower
$ ruby -v code/string/===-vs-=~-vs-match.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#match? 34.609M i/100ms
String#=~ 32.140M i/100ms
Regexp#=== 32.093M i/100ms
String#match 31.486M i/100ms
Calculating -------------------------------------
String#match? 346.266M (± 1.6%) i/s - 1.765B in 5.098792s
String#=~ 320.343M (± 2.0%) i/s - 1.607B in 5.018795s
Regexp#=== 318.901M (± 2.7%) i/s - 1.605B in 5.035708s
String#match 313.223M (± 2.1%) i/s - 1.574B in 5.028493s
Comparison:
String#match?: 346266076.8 i/s
String#=~: 320342972.0 i/s - 1.08x (± 0.00) slower
Regexp#===: 318900904.2 i/s - 1.09x (± 0.00) slower
String#match: 313223364.9 i/s - 1.11x (± 0.00) slower
$ ruby -v code/string/casecmp-vs-downcase-==.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#downcase + == 2.560M i/100ms
String#casecmp 4.398M i/100ms
Calculating -------------------------------------
String#downcase + == 29.613M (± 8.4%) i/s - 148.505M in 5.066940s
String#casecmp 47.831M (± 8.4%) i/s - 237.504M in 5.020792s
Comparison:
String#casecmp: 47831074.2 i/s
String#downcase + ==: 29612821.2 i/s - 1.62x (± 0.00) slower
$ ruby -v code/string/concatenation.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#+ 5.843M i/100ms
String#concat 10.011M i/100ms
String#append 10.103M i/100ms
"foo" "bar" 322.014M i/100ms
"#{'foo'}#{'bar'}" 10.192M i/100ms
Calculating -------------------------------------
String#+ 100.594M (± 6.8%) i/s - 502.518M in 5.021150s
String#concat 101.217M (± 3.8%) i/s - 510.562M in 5.051962s
String#append 100.609M (± 4.8%) i/s - 505.132M in 5.033109s
"foo" "bar" 3.225B (± 0.3%) i/s - 16.423B in 5.092459s
"#{'foo'}#{'bar'}" 100.700M (± 4.3%) i/s - 509.588M in 5.070611s
Comparison:
"foo" "bar": 3224950466.8 i/s
String#concat: 101217060.9 i/s - 31.86x (± 0.00) slower
"#{'foo'}#{'bar'}": 100700276.8 i/s - 32.03x (± 0.00) slower
String#append: 100608885.1 i/s - 32.05x (± 0.00) slower
String#+: 100594347.4 i/s - 32.06x (± 0.00) slower
$ ruby -v code/string/dup-vs-unary-plus.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#+@ 315.028M i/100ms
String#dup 313.457M i/100ms
Calculating -------------------------------------
String#+@ 3.191B (± 2.8%) i/s - 16.066B in 5.038750s
String#dup 3.182B (± 3.1%) i/s - 15.986B in 5.029339s
Comparison:
String#+@: 3191198004.8 i/s
String#dup: 3181982755.2 i/s - same-ish: difference falls within error
$ ruby -v code/string/end-string-checking-match-vs-end_with.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#=~ 1.434M i/100ms
String#match? 1.752M i/100ms
String#end_with? 11.146M i/100ms
Calculating -------------------------------------
String#=~ 14.636M (± 3.2%) i/s - 74.557M in 5.099839s
String#match? 17.606M (± 0.8%) i/s - 89.356M in 5.075608s
String#end_with? 110.279M (± 2.5%) i/s - 557.295M in 5.056861s
Comparison:
String#end_with?: 110278501.8 i/s
String#match?: 17606131.1 i/s - 6.26x (± 0.00) slower
String#=~: 14635740.3 i/s - 7.53x (± 0.00) slower
$ ruby -v code/string/gsub-vs-sub.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#gsub 786.675k i/100ms
String#sub 988.692k i/100ms
String#dup["string"]=
10.401M i/100ms
Calculating -------------------------------------
String#gsub 8.639M (± 8.6%) i/s - 43.267M in 5.062757s
String#sub 9.987M (± 9.9%) i/s - 49.435M in 5.009721s
String#dup["string"]=
103.494M (± 2.1%) i/s - 520.046M in 5.027404s
Comparison:
String#dup["string"]=: 103494345.8 i/s
String#sub: 9986669.4 i/s - 10.36x (± 0.00) slower
String#gsub: 8639013.1 i/s - 11.98x (± 0.00) slower
$ ruby -v code/string/gsub-vs-tr.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#gsub 365.194k i/100ms
String#tr 154.692k i/100ms
Calculating -------------------------------------
String#gsub 4.035M (± 9.1%) i/s - 20.086M in 5.031581s
String#tr 1.541M (± 5.4%) i/s - 7.735M in 5.034963s
Comparison:
String#gsub: 4035369.3 i/s
String#tr: 1540951.1 i/s - 2.62x (± 0.00) slower
$ ruby -v code/string/mutable_vs_immutable_strings.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Without Freeze 314.840M i/100ms
With Freeze 317.292M i/100ms
Calculating -------------------------------------
Without Freeze 3.191B (± 2.4%) i/s - 16.057B in 5.035002s
With Freeze 3.201B (± 2.3%) i/s - 16.182B in 5.057624s
Comparison:
With Freeze: 3201304783.6 i/s
Without Freeze: 3191098169.1 i/s - same-ish: difference falls within error
$ ruby -v code/string/remove-extra-spaces-or-other-chars.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#gsub/regex+/ 8.246k i/100ms
String#squeeze 84.283k i/100ms
Calculating -------------------------------------
String#gsub/regex+/ 153.392k (±12.4%) i/s - 758.632k in 5.046648s
String#squeeze 872.829k (± 4.9%) i/s - 4.383M in 5.034718s
Comparison:
String#squeeze: 872829.4 i/s
String#gsub/regex+/: 153392.2 i/s - 5.69x (± 0.00) slower
$ ruby -v code/string/start-string-checking-match-vs-start_with.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#=~ 9.180M i/100ms
String#match? 13.464M i/100ms
String#start_with? 12.869M i/100ms
Calculating -------------------------------------
String#=~ 97.995M (± 4.6%) i/s - 495.702M in 5.069859s
String#match? 134.389M (± 0.5%) i/s - 673.202M in 5.009507s
String#start_with? 127.790M (± 2.6%) i/s - 643.471M in 5.039154s
Comparison:
String#match?: 134388575.7 i/s
String#start_with?: 127789594.9 i/s - 1.05x (± 0.00) slower
String#=~: 97995156.0 i/s - 1.37x (± 0.00) slower
$ ruby -v code/string/start_with-vs-substring-==.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#start_with? 177.269k i/100ms
String#[0, n] == 146.162k i/100ms
String#[RANGE] == 204.697k i/100ms
String#[0...n] == 141.111k i/100ms
Calculating -------------------------------------
String#start_with? 6.815M (± 4.1%) i/s - 34.036M in 5.006229s
String#[0, n] == 13.750M (±13.1%) i/s - 66.796M in 5.002548s
String#[RANGE] == 14.542M (±12.3%) i/s - 71.030M in 5.005022s
String#[0...n] == 13.917M (±13.3%) i/s - 66.746M in 4.999755s
Comparison:
String#[RANGE] ==: 14542296.9 i/s
String#[0...n] ==: 13916765.0 i/s - same-ish: difference falls within error
String#[0, n] ==: 13749931.0 i/s - same-ish: difference falls within error
String#start_with?: 6814823.6 i/s - 2.13x (± 0.00) slower
$ ruby -v code/string/sub!-vs-gsub!-vs-[]=.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#['string']= 10.126M i/100ms
String#sub!'string' 900.491k i/100ms
String#gsub!'string' 832.433k i/100ms
String#[/regexp/]= 9.832M i/100ms
String#sub!/regexp/ 1.830M i/100ms
String#gsub!/regexp/ 905.996k i/100ms
Calculating -------------------------------------
String#['string']= 102.787M (± 3.1%) i/s - 516.419M in 5.029477s
String#sub!'string' 10.735M (±10.4%) i/s - 53.129M in 5.024803s
String#gsub!'string' 9.232M (±10.1%) i/s - 45.784M in 5.033513s
String#[/regexp/]= 100.352M (± 2.6%) i/s - 501.438M in 5.000678s
String#sub!/regexp/ 30.844M (± 4.8%) i/s - 155.562M in 5.056772s
String#gsub!/regexp/ 9.439M (± 9.9%) i/s - 47.112M in 5.054287s
Comparison:
String#['string']=: 102787440.8 i/s
String#[/regexp/]=: 100351768.4 i/s - same-ish: difference falls within error
String#sub!/regexp/: 30843861.2 i/s - 3.33x (± 0.00) slower
String#sub!'string': 10735022.7 i/s - 9.57x (± 0.00) slower
String#gsub!/regexp/: 9439492.5 i/s - 10.89x (± 0.00) slower
String#gsub!'string': 9232138.1 i/s - 11.13x (± 0.00) slower
$ ruby -v code/string/sub-vs-chomp-vs-delete_suffix.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#sub 8.107M i/100ms
String#chomp 6.056M i/100ms
String#delete_suffix 13.641M i/100ms
Calculating -------------------------------------
String#sub 89.609M (± 8.3%) i/s - 445.890M in 5.013141s
String#chomp 60.515M (± 0.4%) i/s - 302.807M in 5.003956s
String#delete_suffix 154.208M (± 8.8%) i/s - 763.901M in 5.006662s
Comparison:
String#delete_suffix: 154207856.5 i/s
String#sub: 89609042.4 i/s - 1.72x (± 0.00) slower
String#chomp: 60514505.6 i/s - 2.55x (± 0.00) slower
$ ruby -v code/string/sub-vs-delete_prefix.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#delete_prefix 314.432M i/100ms
String#sub 128.907M i/100ms
Calculating -------------------------------------
String#delete_prefix 3.195B (± 3.1%) i/s - 16.036B in 5.024960s
String#sub 1.281B (± 2.6%) i/s - 6.445B in 5.035255s
Comparison:
String#delete_prefix: 3194810004.0 i/s
String#sub: 1281031052.3 i/s - 2.49x (± 0.00) slower
$ ruby -v code/string/unpack1-vs-unpack[0].rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#unpack1 1.610M i/100ms
String#unpack[0] 1.916M i/100ms
Calculating -------------------------------------
String#unpack1 20.046M (± 5.2%) i/s - 101.455M in 5.075473s
String#unpack[0] 20.162M (± 3.1%) i/s - 101.563M in 5.042468s
Comparison:
String#unpack[0]: 20162360.2 i/s
String#unpack1: 20046427.1 i/s - same-ish: difference falls within error
$ ruby -v code/time/iso8601-vs-parse.rb
truffleruby 24.2.0-dev-a92041fd, like ruby 3.2.4, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Time.iso8601 25.090k i/100ms
Time.parse 405.000 i/100ms
Calculating -------------------------------------
Time.iso8601 842.251k (±14.4%) i/s - 4.090M in 5.029414s
Time.parse 5.891k (±23.9%) i/s - 27.135k in 5.021421s
Comparison:
Time.iso8601: 842250.6 i/s
Time.parse: 5890.9 i/s - 142.98x (± 0.00) slower