forked from fastruby/fast-ruby
-
Notifications
You must be signed in to change notification settings - Fork 1
/
truffleruby-3.2.2.fastruby
922 lines (800 loc) · 41.9 KB
/
truffleruby-3.2.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 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Function with single Array argument
313.348M i/100ms
Function with splat arguments
1.847k i/100ms
Calculating -------------------------------------
Function with single Array argument
3.175B (± 3.2%) i/s - 15.981B in 5.039123s
Function with splat arguments
20.076k (±10.3%) i/s - 99.738k in 5.038274s
Comparison:
Function with single Array argument: 3175003888.9 i/s
Function with splat arguments: 20076.3 i/s - 158147.19x (± 0.00) slower
$ ruby -v code/general/assignment.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Parallel Assignment 311.369M i/100ms
Sequential Assignment
308.781M i/100ms
Calculating -------------------------------------
Parallel Assignment 3.149B (± 2.8%) i/s - 15.880B in 5.046915s
Sequential Assignment
3.172B (± 2.4%) i/s - 16.057B in 5.065024s
Comparison:
Sequential Assignment: 3172107482.9 i/s
Parallel Assignment: 3148999027.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-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
getter_and_setter 319.751M i/100ms
attr_accessor 312.010M i/100ms
Calculating -------------------------------------
getter_and_setter 3.168B (± 2.7%) i/s - 15.988B in 5.050863s
attr_accessor 3.181B (± 1.3%) i/s - 15.913B in 5.003029s
Comparison:
attr_accessor: 3181081842.5 i/s
getter_and_setter: 3167694212.9 i/s - same-ish: difference falls within error
$ ruby -v code/general/begin-rescue-vs-respond-to.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
begin...rescue 13.443k i/100ms
respond_to? 302.712M i/100ms
Calculating -------------------------------------
begin...rescue 100.921k (± 9.1%) i/s - 510.834k in 5.116407s
respond_to? 3.181B (± 2.4%) i/s - 16.044B in 5.047379s
Comparison:
respond_to?: 3180535720.4 i/s
begin...rescue: 100921.0 i/s - 31515.11x (± 0.00) slower
$ ruby -v code/general/block-apply-method.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
normal 314.016M i/100ms
&method 18.269M i/100ms
Calculating -------------------------------------
normal 3.153B (± 2.8%) i/s - 16.015B in 5.083051s
&method 181.777M (± 1.6%) i/s - 913.434M in 5.026341s
Comparison:
normal: 3153219772.4 i/s
&method: 181777172.0 i/s - 17.35x (± 0.00) slower
$ ruby -v code/general/define_method-vs-module-eval.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
module_eval with string
158.000 i/100ms
define_method 156.000 i/100ms
Calculating -------------------------------------
module_eval with string
4.089k (±54.1%) i/s - 8.216k in 5.033185s
define_method 11.708k (±44.7%) i/s - 11.232k in 7.070453s
Comparison:
define_method: 11707.6 i/s
module_eval with string: 4089.2 i/s - 2.86x (± 0.00) slower
$ ruby -v code/general/format-vs-round-and-to-s.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Float#round 126.237k i/100ms
Kernel#format 102.607k i/100ms
String#% 101.638k i/100ms
Calculating -------------------------------------
Float#round 1.262M (± 1.9%) i/s - 6.312M in 5.001566s
Kernel#format 1.017M (± 1.9%) i/s - 5.130M in 5.048093s
String#% 1.004M (± 2.8%) i/s - 5.082M in 5.065086s
Comparison:
Float#round: 1262471.9 i/s
Kernel#format: 1016668.9 i/s - 1.24x (± 0.00) slower
String#%: 1004159.9 i/s - 1.26x (± 0.00) slower
$ ruby -v code/general/hash-vs-openstruct-on-access.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash 314.016M i/100ms
OpenStruct 310.006M i/100ms
Calculating -------------------------------------
Hash 3.128B (± 2.1%) i/s - 15.701B in 5.022006s
OpenStruct 3.166B (± 2.3%) i/s - 16.120B in 5.094681s
Comparison:
OpenStruct: 3165902804.9 i/s
Hash: 3127807764.8 i/s - same-ish: difference falls within error
$ ruby -v code/general/hash-vs-openstruct.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash 311.630M i/100ms
OpenStruct 4.761k i/100ms
Calculating -------------------------------------
Hash 2.953B (±11.6%) i/s - 14.647B in 5.059429s
OpenStruct 31.593k (±25.1%) i/s - 152.352k in 5.052666s
Comparison:
Hash: 2952957514.6 i/s
OpenStruct: 31592.8 i/s - 93469.19x (± 0.00) slower
$ ruby -v code/general/inheritance-check.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
less than or equal 964.774k i/100ms
ancestors.include? 215.523k i/100ms
Calculating -------------------------------------
less than or equal 9.797M (± 4.4%) i/s - 49.203M in 5.031551s
ancestors.include? 2.238M (± 6.4%) i/s - 11.207M in 5.037619s
Comparison:
less than or equal: 9797435.4 i/s
ancestors.include?: 2238295.9 i/s - 4.38x (± 0.00) slower
$ ruby -v code/general/loop-vs-while-true.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
While Loop 1.000 i/100ms
Kernel loop 1.000 i/100ms
Calculating -------------------------------------
While Loop 31.740 (± 6.3%) i/s - 159.000 in 5.024317s
Kernel loop 32.080 (± 3.1%) i/s - 161.000 in 5.025973s
Comparison:
Kernel loop: 32.1 i/s
While Loop: 31.7 i/s - same-ish: difference falls within error
$ ruby -v code/general/raise-vs-e2mmap.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
$ ruby -v code/array/array-first-vs-index.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#[0] 319.080M i/100ms
Array#first 318.831M i/100ms
Calculating -------------------------------------
Array#[0] 3.204B (± 2.0%) i/s - 16.273B in 5.081867s
Array#first 3.197B (± 2.2%) i/s - 16.260B in 5.089115s
Comparison:
Array#[0]: 3203634776.6 i/s
Array#first: 3196758038.2 i/s - same-ish: difference falls within error
$ ruby -v code/array/array-last-vs-index.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#[-1] 320.671M i/100ms
Array#last 316.762M i/100ms
Calculating -------------------------------------
Array#[-1] 3.183B (± 1.9%) i/s - 16.034B in 5.038855s
Array#last 3.199B (± 1.6%) i/s - 16.155B in 5.050779s
Comparison:
Array#last: 3199310267.5 i/s
Array#[-1]: 3183260147.8 i/s - same-ish: difference falls within error
$ ruby -v code/array/bsearch-vs-find.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
find 1.000 i/100ms
bsearch 884.923k i/100ms
Calculating -------------------------------------
find 13.725 (± 0.0%) i/s - 69.000 in 5.030655s
bsearch 9.347M (± 2.8%) i/s - 46.901M in 5.021882s
Comparison:
bsearch: 9346838.1 i/s
find: 13.7 i/s - 680998.71x (± 0.00) slower
$ ruby -v code/array/insert-vs-unshift.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.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.212 (± 0.0%) i/s - 2.000 in 9.436360s
Array#insert 1.398 (± 0.0%) i/s - 7.000 in 5.007240s
Comparison:
Array#insert: 1.4 i/s
Array#unshift: 0.2 i/s - 6.60x (± 0.00) slower
$ ruby -v code/array/length-vs-size-vs-count.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#length 317.653M i/100ms
Array#size 304.350M i/100ms
Array#count 314.014M i/100ms
Calculating -------------------------------------
Array#length 3.197B (± 1.4%) i/s - 16.200B in 5.068752s
Array#size 3.202B (± 1.1%) i/s - 16.131B in 5.038258s
Array#count 3.190B (± 1.8%) i/s - 16.015B in 5.021827s
Comparison:
Array#size: 3201969064.5 i/s
Array#length: 3196796867.4 i/s - same-ish: difference falls within error
Array#count: 3190065091.3 i/s - same-ish: difference falls within error
$ ruby -v code/array/shuffle-first-vs-sample.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#shuffle.first 36.908k i/100ms
Array#sample 3.886M i/100ms
Calculating -------------------------------------
Array#shuffle.first 372.655k (± 1.7%) i/s - 1.882M in 5.052642s
Array#sample 38.692M (± 1.8%) i/s - 194.284M in 5.023010s
Comparison:
Array#sample: 38692441.9 i/s
Array#shuffle.first: 372654.9 i/s - 103.83x (± 0.00) slower
$ ruby -v code/date/iso8601-vs-parse.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Date.iso8601 969.000 i/100ms
Date.parse 624.000 i/100ms
Calculating -------------------------------------
Date.iso8601 17.622k (±35.3%) i/s - 79.458k in 5.008214s
Date.parse 8.406k (±21.7%) i/s - 39.936k in 5.053751s
Comparison:
Date.iso8601: 17621.6 i/s
Date.parse: 8406.3 i/s - 2.10x (± 0.00) slower
$ ruby -v code/enumerable/each-push-vs-map.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#each + push 328.108k i/100ms
Array#map 1.785M i/100ms
Calculating -------------------------------------
Array#each + push 3.575M (± 8.2%) i/s - 18.046M in 5.091220s
Array#map 18.719M (± 9.8%) i/s - 92.842M in 5.021843s
Comparison:
Array#map: 18718508.6 i/s
Array#each + push: 3575325.0 i/s - 5.24x (± 0.00) slower
$ ruby -v code/enumerable/each-vs-for-loop.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
For loop 12.809M i/100ms
#each 35.669M i/100ms
Calculating -------------------------------------
For loop 128.599M (± 2.3%) i/s - 653.273M in 5.082740s
#each 356.017M (± 2.3%) i/s - 1.783B in 5.012221s
Comparison:
#each: 356016667.4 i/s
For loop: 128599379.6 i/s - 2.77x (± 0.00) slower
$ ruby -v code/enumerable/each_with_index-vs-while-loop.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
While Loop 1.406M i/100ms
each_with_index 2.339M i/100ms
Calculating -------------------------------------
While Loop 14.258M (± 2.2%) i/s - 71.700M in 5.031307s
each_with_index 23.376M (± 3.3%) i/s - 116.937M in 5.007699s
Comparison:
each_with_index: 23375651.3 i/s
While Loop: 14257728.3 i/s - 1.64x (± 0.00) slower
$ ruby -v code/enumerable/inject-symbol-vs-block.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
inject symbol 309.329k i/100ms
inject to_proc 309.826k i/100ms
inject block 310.111k i/100ms
Calculating -------------------------------------
inject symbol 3.101M (± 3.2%) i/s - 15.776M in 5.093464s
inject to_proc 3.101M (± 2.7%) i/s - 15.491M in 5.000019s
inject block 3.092M (± 4.2%) i/s - 15.506M in 5.024698s
Comparison:
inject symbol: 3100932.1 i/s
inject to_proc: 3100813.2 i/s - same-ish: difference falls within error
inject block: 3092159.8 i/s - same-ish: difference falls within error
$ ruby -v code/enumerable/map-flatten-vs-flat_map.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#map.flatten(1) 23.271k i/100ms
Array#map.flatten 26.110k i/100ms
Array#flat_map 57.736k i/100ms
Calculating -------------------------------------
Array#map.flatten(1) 267.038k (± 7.2%) i/s - 1.326M in 4.999968s
Array#map.flatten 263.251k (± 7.3%) i/s - 1.332M in 5.091321s
Array#flat_map 583.789k (± 3.1%) i/s - 2.945M in 5.048866s
Comparison:
Array#flat_map: 583788.8 i/s
Array#map.flatten(1): 267038.0 i/s - 2.19x (± 0.00) slower
Array#map.flatten: 263250.6 i/s - 2.22x (± 0.00) slower
$ ruby -v code/enumerable/reverse-each-vs-reverse_each.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#reverse.each 305.395k i/100ms
Array#reverse_each 2.336M i/100ms
Calculating -------------------------------------
Array#reverse.each 3.452M (± 6.3%) i/s - 17.408M in 5.070217s
Array#reverse_each 23.835M (± 6.4%) i/s - 119.122M in 5.015932s
Comparison:
Array#reverse_each: 23834910.7 i/s
Array#reverse.each: 3452067.0 i/s - 6.90x (± 0.00) slower
$ ruby -v code/enumerable/select-first-vs-detect.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#select.first
952.224k i/100ms
Enumerable#detect 4.683M i/100ms
Calculating -------------------------------------
Enumerable#select.first
10.435M (± 7.0%) i/s - 207.585M in 20.024451s
Enumerable#detect 46.601M (± 2.5%) i/s - 931.936M in 20.013203s
Comparison:
Enumerable#detect: 46600807.5 i/s
Enumerable#select.first: 10434831.4 i/s - 4.47x (± 0.00) slower
$ ruby -v code/enumerable/select-last-vs-reverse-detect.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#reverse.detect
347.090k i/100ms
Enumerable#select.last
540.879k i/100ms
Calculating -------------------------------------
Enumerable#reverse.detect
3.398M (± 5.9%) i/s - 17.007M in 5.029151s
Enumerable#select.last
5.332M (± 7.6%) i/s - 26.503M in 5.021665s
Comparison:
Enumerable#select.last: 5331893.6 i/s
Enumerable#reverse.detect: 3397751.0 i/s - 1.57x (± 0.00) slower
$ ruby -v code/enumerable/sort-vs-sort_by.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#sort_by (Symbol#to_proc)
2.880k i/100ms
Enumerable#sort_by 4.224k i/100ms
Enumerable#sort 4.876k i/100ms
Calculating -------------------------------------
Enumerable#sort_by (Symbol#to_proc)
41.424k (±10.9%) i/s - 204.480k in 5.043803s
Enumerable#sort_by 34.858k (±35.1%) i/s - 135.168k in 5.027818s
Enumerable#sort 55.830k (± 4.0%) i/s - 282.808k in 5.074354s
Comparison:
Enumerable#sort: 55830.2 i/s
Enumerable#sort_by (Symbol#to_proc): 41424.0 i/s - 1.35x (± 0.00) slower
Enumerable#sort_by: 34857.9 i/s - 1.60x (± 0.00) slower
$ ruby -v code/enumerable/sort_by-first-vs-min_by.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#min_by 992.440k i/100ms
Enumerable#sort_by...first
9.814k i/100ms
Calculating -------------------------------------
Enumerable#min_by 9.863M (± 1.4%) i/s - 49.622M in 5.032096s
Enumerable#sort_by...first
106.090k (± 5.7%) i/s - 529.956k in 5.019778s
Comparison:
Enumerable#min_by: 9862983.9 i/s
Enumerable#sort_by...first: 106090.4 i/s - 92.97x (± 0.00) slower
$ ruby -v code/hash/bracket-vs-dup.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash[] 652.468k i/100ms
Hash#dup 711.181k i/100ms
Calculating -------------------------------------
Hash[] 7.745M (± 9.2%) i/s - 38.496M in 5.039866s
Hash#dup 7.528M (±12.2%) i/s - 37.693M in 5.086931s
Comparison:
Hash[]: 7745188.9 i/s
Hash#dup: 7527736.6 i/s - same-ish: difference falls within error
$ ruby -v code/hash/bracket-vs-fetch.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#[], symbol 322.470M i/100ms
Hash#fetch, symbol 317.693M i/100ms
Hash#[], string 20.196M i/100ms
Hash#fetch, string 17.817M i/100ms
Calculating -------------------------------------
Hash#[], symbol 3.165B (± 2.7%) i/s - 16.123B in 5.097580s
Hash#fetch, symbol 3.148B (± 2.6%) i/s - 15.885B in 5.049866s
Hash#[], string 200.933M (± 1.9%) i/s - 1.010B in 5.027698s
Hash#fetch, string 179.231M (± 0.3%) i/s - 908.681M in 5.069934s
Comparison:
Hash#[], symbol: 3165369463.9 i/s
Hash#fetch, symbol: 3147696619.8 i/s - same-ish: difference falls within error
Hash#[], string: 200933122.7 i/s - 15.75x (± 0.00) slower
Hash#fetch, string: 179231391.1 i/s - 17.66x (± 0.00) slower
$ ruby -v code/hash/dig-vs-[]-vs-fetch.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#dig 91.557M i/100ms
Hash#[] 91.228M i/100ms
Hash#[] || 92.178M i/100ms
Hash#[] && 92.359M i/100ms
Hash#fetch 92.316M i/100ms
Hash#fetch fallback 92.379M i/100ms
Calculating -------------------------------------
Hash#dig 914.816M (± 2.6%) i/s - 4.578B in 5.007769s
Hash#[] 920.999M (± 0.8%) i/s - 4.653B in 5.052061s
Hash#[] || 916.524M (± 1.9%) i/s - 4.609B in 5.030604s
Hash#[] && 918.400M (± 1.5%) i/s - 4.618B in 5.029459s
Hash#fetch 922.463M (± 0.5%) i/s - 4.616B in 5.003897s
Hash#fetch fallback 922.896M (± 0.2%) i/s - 4.619B in 5.004887s
Comparison:
Hash#fetch fallback: 922895676.4 i/s
Hash#fetch: 922462708.1 i/s - same-ish: difference falls within error
Hash#[]: 920998708.4 i/s - same-ish: difference falls within error
Hash#[] &&: 918399744.6 i/s - same-ish: difference falls within error
Hash#[] ||: 916523804.4 i/s - same-ish: difference falls within error
Hash#dig: 914815992.8 i/s - same-ish: difference falls within error
$ ruby -v code/hash/fetch-vs-fetch-with-block.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#fetch + const 312.196M i/100ms
Hash#fetch + block 319.314M i/100ms
Hash#fetch + arg 316.749M i/100ms
Calculating -------------------------------------
Hash#fetch + const 3.183B (± 2.9%) i/s - 15.922B in 5.006434s
Hash#fetch + block 3.198B (± 2.7%) i/s - 16.285B in 5.096546s
Hash#fetch + arg 3.151B (± 2.3%) i/s - 15.837B in 5.028501s
Comparison:
Hash#fetch + block: 3197877682.2 i/s
Hash#fetch + const: 3183295742.3 i/s - same-ish: difference falls within error
Hash#fetch + arg: 3151310671.2 i/s - same-ish: difference falls within error
$ ruby -v code/hash/hash-key-sort_by-vs-sort.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
sort_by + to_h 20.769k i/100ms
sort + to_h 4.886k i/100ms
Calculating -------------------------------------
sort_by + to_h 532.882k (± 9.4%) i/s - 2.638M in 5.020974s
sort + to_h 206.190k (±12.6%) i/s - 1.007M in 5.006608s
Comparison:
sort_by + to_h: 532881.6 i/s
sort + to_h: 206189.8 i/s - 2.58x (± 0.00) slower
$ ruby -v code/hash/keys-each-vs-each_key.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#keys.each 135.158k i/100ms
Hash#each_key 201.526k i/100ms
Calculating -------------------------------------
Hash#keys.each 2.027M (± 9.7%) i/s - 10.002M in 5.054265s
Hash#each_key 2.127M (± 5.7%) i/s - 10.882M in 5.140929s
Comparison:
Hash#each_key: 2126569.3 i/s
Hash#keys.each: 2026821.2 i/s - same-ish: difference falls within error
$ ruby -v code/hash/keys-include-vs-key.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#keys.include? 280.000 i/100ms
Hash#key? 3.530M i/100ms
Calculating -------------------------------------
Hash#keys.include? 3.619k (±12.1%) i/s - 17.920k in 5.064568s
Hash#key? 35.180M (± 0.5%) i/s - 176.498M in 5.017057s
Comparison:
Hash#key?: 35180415.7 i/s
Hash#keys.include?: 3618.7 i/s - 9721.80x (± 0.00) slower
$ ruby -v code/hash/merge-bang-vs-[]=.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#merge! 52.484k i/100ms
Hash#[]= 59.157k i/100ms
Calculating -------------------------------------
Hash#merge! 574.307k (± 8.2%) i/s - 2.887M in 5.073167s
Hash#[]= 608.978k (± 7.4%) i/s - 3.076M in 5.085424s
Comparison:
Hash#[]=: 608977.8 i/s
Hash#merge!: 574306.5 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-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
{}#merge!(Hash) do end
41.285k i/100ms
Hash#merge({}) 19.504k i/100ms
Hash#dup#merge!({}) 32.222k i/100ms
Calculating -------------------------------------
{}#merge!(Hash) do end
386.660k (±10.4%) i/s - 1.940M in 5.084840s
Hash#merge({}) 194.820k (± 9.1%) i/s - 975.200k in 5.053682s
Hash#dup#merge!({}) 318.921k (± 9.2%) i/s - 1.579M in 5.002706s
Comparison:
{}#merge!(Hash) do end: 386659.5 i/s
Hash#dup#merge!({}): 318921.0 i/s - same-ish: difference falls within error
Hash#merge({}): 194820.3 i/s - 1.98x (± 0.00) slower
$ ruby -v code/hash/merge-vs-double-splat-operator.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#**other 302.254M i/100ms
Hash#merge 312.302M i/100ms
Calculating -------------------------------------
Hash#**other 3.169B (± 2.6%) i/s - 16.019B in 5.059573s
Hash#merge 3.202B (± 2.0%) i/s - 16.240B in 5.073374s
Comparison:
Hash#merge: 3202395526.1 i/s
Hash#**other: 3168517999.9 i/s - same-ish: difference falls within error
$ ruby -v code/hash/merge-vs-merge-bang.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#merge 858.000 i/100ms
Hash#merge! 59.824k i/100ms
Calculating -------------------------------------
Hash#merge 12.398k (±12.6%) i/s - 61.776k in 5.078677s
Hash#merge! 601.068k (± 8.2%) i/s - 2.991M in 5.014825s
Comparison:
Hash#merge!: 601068.2 i/s
Hash#merge: 12397.6 i/s - 48.48x (± 0.00) slower
$ ruby -v code/hash/slice-native-vs-before-native.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#native-slice 1.610M i/100ms
Array#each 1.345M i/100ms
Array#each_w/_object 1.468M i/100ms
Hash#select-include 2.523M i/100ms
Calculating -------------------------------------
Hash#native-slice 18.652M (± 7.0%) i/s - 93.367M in 5.038476s
Array#each 15.287M (± 5.9%) i/s - 76.648M in 5.039088s
Array#each_w/_object 15.157M (± 5.8%) i/s - 76.353M in 5.061253s
Hash#select-include 24.372M (± 5.7%) i/s - 123.650M in 5.095194s
Comparison:
Hash#select-include : 24372220.9 i/s
Hash#native-slice : 18652131.2 i/s - 1.31x (± 0.00) slower
Array#each : 15286692.0 i/s - 1.59x (± 0.00) slower
Array#each_w/_object: 15157124.6 i/s - 1.61x (± 0.00) slower
$ ruby -v code/hash/values-include-vs-value.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#values.include? 269.000 i/100ms
Hash#value? 678.000 i/100ms
Calculating -------------------------------------
Hash#values.include? 2.972k (±11.0%) i/s - 14.795k in 5.064744s
Hash#value? 6.726k (± 1.0%) i/s - 33.900k in 5.040820s
Comparison:
Hash#value?: 6725.8 i/s
Hash#values.include?: 2972.4 i/s - 2.26x (± 0.00) slower
$ ruby -v code/method/call-vs-send-vs-method_missing.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
call 318.291M i/100ms
send 322.373M i/100ms
method_missing 318.046M i/100ms
Calculating -------------------------------------
call 3.196B (± 2.5%) i/s - 16.233B in 5.083210s
send 3.204B (± 2.3%) i/s - 16.119B in 5.034128s
method_missing 3.177B (± 3.0%) i/s - 15.902B in 5.009891s
Comparison:
send: 3203863222.4 i/s
call: 3195590060.0 i/s - same-ish: difference falls within error
method_missing: 3177414812.4 i/s - same-ish: difference falls within error
$ ruby -v code/proc-and-block/block-vs-to_proc.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Block 46.486k i/100ms
Symbol#to_proc 70.206k i/100ms
Calculating -------------------------------------
Block 747.294k (±16.6%) i/s - 3.626M in 5.015000s
Symbol#to_proc 767.692k (±10.6%) i/s - 3.791M in 5.026165s
Comparison:
Symbol#to_proc: 767692.3 i/s
Block: 747294.3 i/s - same-ish: difference falls within error
$ ruby -v code/proc-and-block/proc-call-vs-yield.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
block.call 317.383M i/100ms
block + yield 313.086M i/100ms
unused block 320.664M i/100ms
yield 322.836M i/100ms
Calculating -------------------------------------
block.call 3.202B (± 2.2%) i/s - 16.187B in 5.057953s
block + yield 3.213B (± 1.7%) i/s - 16.280B in 5.069427s
unused block 3.184B (± 3.1%) i/s - 16.033B in 5.040433s
yield 3.184B (± 2.1%) i/s - 16.142B in 5.072332s
Comparison:
block + yield: 3212558799.3 i/s
block.call: 3201852856.8 i/s - same-ish: difference falls within error
unused block: 3184271822.1 i/s - same-ish: difference falls within error
yield: 3183720237.8 i/s - same-ish: difference falls within error
$ ruby -v code/range/cover-vs-include.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
range#cover? 4.985k i/100ms
range#include? 184.000 i/100ms
range#member? 209.000 i/100ms
plain compare 7.421k i/100ms
Calculating -------------------------------------
range#cover? 59.203k (±29.1%) i/s - 269.190k in 5.089678s
range#include? 2.903k (±32.9%) i/s - 12.696k in 5.078022s
range#member? 2.710k (±35.1%) i/s - 11.704k in 5.013943s
plain compare 88.318k (±23.6%) i/s - 408.155k in 5.041542s
Comparison:
plain compare: 88317.7 i/s
range#cover?: 59202.6 i/s - same-ish: difference falls within error
range#include?: 2902.7 i/s - 30.43x (± 0.00) slower
range#member?: 2710.2 i/s - 32.59x (± 0.00) slower
$ ruby -v code/string/===-vs-=~-vs-match.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#match? 16.664M i/100ms
String#=~ 15.362M i/100ms
Regexp#=== 15.387M i/100ms
String#match 12.695M i/100ms
Calculating -------------------------------------
String#match? 168.087M (± 2.1%) i/s - 849.875M in 5.058686s
String#=~ 154.350M (± 1.5%) i/s - 783.437M in 5.076978s
Regexp#=== 152.247M (± 6.3%) i/s - 769.325M in 5.086355s
String#match 128.340M (± 1.0%) i/s - 647.439M in 5.045223s
Comparison:
String#match?: 168087154.4 i/s
String#=~: 154350141.1 i/s - 1.09x (± 0.00) slower
Regexp#===: 152246770.0 i/s - 1.10x (± 0.00) slower
String#match: 128339595.7 i/s - 1.31x (± 0.00) slower
$ ruby -v code/string/casecmp-vs-downcase-==.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#downcase + == 2.718M i/100ms
String#casecmp 4.549M i/100ms
Calculating -------------------------------------
String#downcase + == 30.887M (± 6.3%) i/s - 154.939M in 5.043471s
String#casecmp 48.689M (± 5.0%) i/s - 245.656M in 5.058417s
Comparison:
String#casecmp: 48689356.5 i/s
String#downcase + ==: 30886598.6 i/s - 1.58x (± 0.00) slower
$ ruby -v code/string/concatenation.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#+ 9.661M i/100ms
String#concat 9.735M i/100ms
String#append 10.262M i/100ms
"foo" "bar" 317.345M i/100ms
"#{'foo'}#{'bar'}" 10.466M i/100ms
Calculating -------------------------------------
String#+ 103.039M (± 6.3%) i/s - 521.715M in 5.090542s
String#concat 103.584M (± 5.6%) i/s - 515.954M in 5.002976s
String#append 103.250M (± 6.0%) i/s - 523.370M in 5.094017s
"foo" "bar" 3.202B (± 1.5%) i/s - 16.185B in 5.056114s
"#{'foo'}#{'bar'}" 102.684M (± 7.0%) i/s - 512.843M in 5.027948s
Comparison:
"foo" "bar": 3201691183.4 i/s
String#concat: 103584053.7 i/s - 30.91x (± 0.00) slower
String#append: 103249716.9 i/s - 31.01x (± 0.00) slower
String#+: 103038912.0 i/s - 31.07x (± 0.00) slower
"#{'foo'}#{'bar'}": 102684300.6 i/s - 31.18x (± 0.00) slower
$ ruby -v code/string/dup-vs-unary-plus.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#+@ 321.021M i/100ms
String#dup 315.802M i/100ms
Calculating -------------------------------------
String#+@ 3.192B (± 1.4%) i/s - 16.051B in 5.029235s
String#dup 3.198B (± 1.9%) i/s - 16.106B in 5.037986s
Comparison:
String#dup: 3198086419.8 i/s
String#+@: 3192205650.1 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-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#=~ 1.373M i/100ms
String#match? 1.609M i/100ms
String#end_with? 11.132M i/100ms
Calculating -------------------------------------
String#=~ 14.055M (± 3.1%) i/s - 71.415M in 5.086172s
String#match? 15.980M (± 2.2%) i/s - 80.453M in 5.037136s
String#end_with? 110.684M (± 1.8%) i/s - 556.618M in 5.030593s
Comparison:
String#end_with?: 110684205.4 i/s
String#match?: 15980159.2 i/s - 6.93x (± 0.00) slower
String#=~: 14054920.8 i/s - 7.88x (± 0.00) slower
$ ruby -v code/string/gsub-vs-sub.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#gsub 768.220k i/100ms
String#sub 938.840k i/100ms
String#dup["string"]=
10.325M i/100ms
Calculating -------------------------------------
String#gsub 8.617M (± 8.3%) i/s - 43.020M in 5.037206s
String#sub 9.890M (± 8.9%) i/s - 49.759M in 5.079460s
String#dup["string"]=
103.439M (± 2.4%) i/s - 526.591M in 5.094228s
Comparison:
String#dup["string"]=: 103439240.8 i/s
String#sub: 9889563.3 i/s - 10.46x (± 0.00) slower
String#gsub: 8617403.7 i/s - 12.00x (± 0.00) slower
$ ruby -v code/string/gsub-vs-tr.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#gsub 220.935k i/100ms
String#tr 143.983k i/100ms
Calculating -------------------------------------
String#gsub 3.956M (± 9.6%) i/s - 19.663M in 5.030581s
String#tr 1.464M (± 3.0%) i/s - 7.343M in 5.020710s
Comparison:
String#gsub: 3955709.2 i/s
String#tr: 1464038.2 i/s - 2.70x (± 0.00) slower
$ ruby -v code/string/mutable_vs_immutable_strings.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Without Freeze 321.564M i/100ms
With Freeze 306.049M i/100ms
Calculating -------------------------------------
Without Freeze 3.171B (± 3.0%) i/s - 16.078B in 5.074803s
With Freeze 3.200B (± 1.9%) i/s - 16.221B in 5.071231s
Comparison:
With Freeze: 3199791150.5 i/s
Without Freeze: 3171439276.2 i/s - same-ish: difference falls within error
$ ruby -v code/string/remove-extra-spaces-or-other-chars.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#gsub/regex+/ 10.025k i/100ms
String#squeeze 85.079k i/100ms
Calculating -------------------------------------
String#gsub/regex+/ 153.033k (±10.0%) i/s - 761.900k in 5.048184s
String#squeeze 832.357k (± 5.1%) i/s - 4.169M in 5.021530s
Comparison:
String#squeeze: 832357.3 i/s
String#gsub/regex+/: 153032.6 i/s - 5.44x (± 0.00) slower
$ ruby -v code/string/start-string-checking-match-vs-start_with.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#=~ 3.274M i/100ms
String#match? 5.215M i/100ms
String#start_with? 13.457M i/100ms
Calculating -------------------------------------
String#=~ 45.498M (± 3.6%) i/s - 229.147M in 5.043305s
String#match? 54.602M (± 2.5%) i/s - 276.390M in 5.065731s
String#start_with? 134.138M (± 0.9%) i/s - 672.849M in 5.016559s
Comparison:
String#start_with?: 134137891.4 i/s
String#match?: 54601688.0 i/s - 2.46x (± 0.00) slower
String#=~: 45497508.3 i/s - 2.95x (± 0.00) slower
$ ruby -v code/string/start_with-vs-substring-==.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#start_with? 64.929k i/100ms
String#[0, n] == 268.889k i/100ms
String#[RANGE] == 410.896k i/100ms
String#[0...n] == 259.967k i/100ms
Calculating -------------------------------------
String#start_with? 6.300M (± 4.1%) i/s - 31.426M in 5.002098s
String#[0, n] == 2.943M (± 4.8%) i/s - 14.789M in 5.037756s
String#[RANGE] == 4.292M (± 3.4%) i/s - 21.777M in 5.080316s
String#[0...n] == 2.586M (± 6.4%) i/s - 12.998M in 5.054995s
Comparison:
String#start_with?: 6299503.7 i/s
String#[RANGE] ==: 4291905.0 i/s - 1.47x (± 0.00) slower
String#[0, n] ==: 2942966.2 i/s - 2.14x (± 0.00) slower
String#[0...n] ==: 2585549.0 i/s - 2.44x (± 0.00) slower
$ ruby -v code/string/sub!-vs-gsub!-vs-[]=.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#['string']= 10.284M i/100ms
String#sub!'string' 849.395k i/100ms
String#gsub!'string' 834.116k i/100ms
String#[/regexp/]= 2.686M i/100ms
String#sub!/regexp/ 2.624M i/100ms
String#gsub!/regexp/ 820.040k i/100ms
Calculating -------------------------------------
String#['string']= 100.880M (± 2.0%) i/s - 514.197M in 5.099280s
String#sub!'string' 10.429M (± 9.3%) i/s - 51.813M in 5.019863s
String#gsub!'string' 8.989M (± 9.7%) i/s - 45.042M in 5.068743s
String#[/regexp/]= 26.434M (± 3.9%) i/s - 134.276M in 5.087675s
String#sub!/regexp/ 25.829M (± 3.5%) i/s - 131.202M in 5.086309s
String#gsub!/regexp/ 8.250M (±10.2%) i/s - 41.002M in 5.032510s
Comparison:
String#['string']=: 100879741.7 i/s
String#[/regexp/]=: 26434409.5 i/s - 3.82x (± 0.00) slower
String#sub!/regexp/: 25828758.6 i/s - 3.91x (± 0.00) slower
String#sub!'string': 10428767.3 i/s - 9.67x (± 0.00) slower
String#gsub!'string': 8988782.5 i/s - 11.22x (± 0.00) slower
String#gsub!/regexp/: 8249582.9 i/s - 12.23x (± 0.00) slower
$ ruby -v code/string/sub-vs-chomp-vs-delete_suffix.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#sub 2.930M i/100ms
String#chomp 5.895M i/100ms
String#delete_suffix 15.189M i/100ms
Calculating -------------------------------------
String#sub 30.475M (± 3.4%) i/s - 152.342M in 5.005061s
String#chomp 58.928M (± 2.6%) i/s - 294.758M in 5.005692s
String#delete_suffix 146.179M (± 8.5%) i/s - 729.067M in 5.029569s
Comparison:
String#delete_suffix: 146178905.0 i/s
String#chomp: 58928415.2 i/s - 2.48x (± 0.00) slower
String#sub: 30475156.9 i/s - 4.80x (± 0.00) slower
$ ruby -v code/string/sub-vs-delete_prefix.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#delete_prefix 319.675M i/100ms
String#sub 15.799M i/100ms
Calculating -------------------------------------
String#delete_prefix 3.153B (± 4.1%) i/s - 15.984B in 5.078319s
String#sub 157.158M (± 1.8%) i/s - 789.940M in 5.028128s
Comparison:
String#delete_prefix: 3153219751.8 i/s
String#sub: 157157898.5 i/s - 20.06x (± 0.00) slower
$ ruby -v code/string/unpack1-vs-unpack[0].rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#unpack1 1.951M i/100ms
String#unpack[0] 2.008M i/100ms
Calculating -------------------------------------
String#unpack1 19.842M (± 2.6%) i/s - 99.490M in 5.017488s
String#unpack[0] 19.766M (± 5.3%) i/s - 100.420M in 5.100734s
Comparison:
String#unpack1: 19842206.5 i/s
String#unpack[0]: 19766124.3 i/s - same-ish: difference falls within error
$ ruby -v code/time/iso8601-vs-parse.rb
truffleruby 24.2.0-dev-829012c1, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Time.iso8601 38.781k i/100ms
Time.parse 337.000 i/100ms
Calculating -------------------------------------
Time.iso8601 449.711k (±25.7%) i/s - 2.094M in 5.068760s
Time.parse 6.299k (±13.0%) i/s - 30.667k in 5.016228s
Comparison:
Time.iso8601: 449710.6 i/s
Time.parse: 6298.8 i/s - 71.40x (± 0.00) slower