forked from fastruby/fast-ruby
-
Notifications
You must be signed in to change notification settings - Fork 1
/
truffleruby-3.0.3.fastruby
922 lines (800 loc) · 41.9 KB
/
truffleruby-3.0.3.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-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Function with single Array argument
238.408M i/100ms
Function with splat arguments
548.000 i/100ms
Calculating -------------------------------------
Function with single Array argument
2.385B (± 0.5%) i/s - 12.159B in 5.097528s
Function with splat arguments
6.196k (± 5.2%) i/s - 31.236k in 5.055582s
Comparison:
Function with single Array argument: 2385294037.2 i/s
Function with splat arguments: 6196.5 i/s - 384944.10x (± 0.00) slower
$ ruby -v code/general/assignment.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Parallel Assignment 238.609M i/100ms
Sequential Assignment
238.590M i/100ms
Calculating -------------------------------------
Parallel Assignment 2.385B (± 0.4%) i/s - 11.930B in 5.002613s
Sequential Assignment
2.388B (± 0.3%) i/s - 12.168B in 5.094979s
Comparison:
Sequential Assignment: 2388264524.3 i/s
Parallel Assignment: 2384882782.4 i/s - same-ish: difference falls within error
$ ruby -v code/general/attr-accessor-vs-getter-and-setter.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
getter_and_setter 238.546M i/100ms
attr_accessor 238.443M i/100ms
Calculating -------------------------------------
getter_and_setter 2.386B (± 0.3%) i/s - 12.166B in 5.098343s
attr_accessor 2.389B (± 0.2%) i/s - 12.161B in 5.089850s
Comparison:
attr_accessor: 2389191639.4 i/s
getter_and_setter: 2386263087.7 i/s - same-ish: difference falls within error
$ ruby -v code/general/begin-rescue-vs-respond-to.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
begin...rescue 7.188k i/100ms
respond_to? 238.615M i/100ms
Calculating -------------------------------------
begin...rescue 51.809k (± 3.0%) i/s - 265.956k in 5.137965s
respond_to? 2.388B (± 0.2%) i/s - 12.169B in 5.096095s
Comparison:
respond_to?: 2387987435.6 i/s
begin...rescue: 51809.2 i/s - 46091.99x (± 0.00) slower
$ ruby -v code/general/block-apply-method.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
normal 238.539M i/100ms
&method 238.499M i/100ms
Calculating -------------------------------------
normal 2.384B (± 0.5%) i/s - 11.927B in 5.003232s
&method 2.387B (± 0.5%) i/s - 12.163B in 5.096427s
Comparison:
&method: 2386714133.4 i/s
normal: 2383908688.3 i/s - same-ish: difference falls within error
$ ruby -v code/general/define_method-vs-module-eval.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
module_eval with string
99.000 i/100ms
define_method 123.000 i/100ms
Calculating -------------------------------------
module_eval with string
1.236k (±29.8%) i/s - 4.158k in 5.967109s
define_method 2.390k (±46.0%) i/s - 4.920k in 5.252053s
Comparison:
define_method: 2389.7 i/s
module_eval with string: 1236.3 i/s - same-ish: difference falls within error
$ ruby -v code/general/format-vs-round-and-to-s.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Float#round 70.789k i/100ms
Kernel#format 63.759k i/100ms
String#% 64.046k i/100ms
Calculating -------------------------------------
Float#round 783.387k (± 2.8%) i/s - 3.964M in 5.064566s
Kernel#format 638.903k (± 2.3%) i/s - 3.252M in 5.092256s
String#% 639.419k (± 2.3%) i/s - 3.202M in 5.010919s
Comparison:
Float#round: 783386.9 i/s
String#%: 639419.1 i/s - 1.23x (± 0.00) slower
Kernel#format: 638903.1 i/s - 1.23x (± 0.00) slower
$ ruby -v code/general/hash-vs-openstruct-on-access.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash 238.313M i/100ms
OpenStruct 238.145M i/100ms
Calculating -------------------------------------
Hash 2.386B (± 0.3%) i/s - 12.154B in 5.094655s
OpenStruct 2.387B (± 0.2%) i/s - 12.145B in 5.087905s
Comparison:
OpenStruct: 2387118955.5 i/s
Hash: 2385644925.6 i/s - same-ish: difference falls within error
$ ruby -v code/general/hash-vs-openstruct.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash 238.553M i/100ms
OpenStruct 2.527k i/100ms
Calculating -------------------------------------
Hash 2.379B (± 0.7%) i/s - 11.928B in 5.014716s
OpenStruct 27.728k (±10.0%) i/s - 136.458k in 5.001306s
Comparison:
Hash: 2378658539.6 i/s
OpenStruct: 27728.3 i/s - 85784.37x (± 0.00) slower
$ ruby -v code/general/inheritance-check.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
less than or equal 711.822k i/100ms
ancestors.include? 135.428k i/100ms
Calculating -------------------------------------
less than or equal 7.777M (± 3.6%) i/s - 39.150M in 5.040722s
ancestors.include? 1.366M (± 4.2%) i/s - 6.907M in 5.065606s
Comparison:
less than or equal: 7777191.8 i/s
ancestors.include?: 1365937.5 i/s - 5.69x (± 0.00) slower
$ ruby -v code/general/loop-vs-while-true.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
While Loop 1.000 i/100ms
Kernel loop 1.000 i/100ms
Calculating -------------------------------------
While Loop 23.861 (± 0.0%) i/s - 120.000 in 5.029341s
Kernel loop 23.889 (± 0.0%) i/s - 120.000 in 5.023333s
Comparison:
Kernel loop: 23.9 i/s
While Loop: 23.9 i/s - 1.00x (± 0.00) slower
$ ruby -v code/general/raise-vs-e2mmap.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
$ ruby -v code/array/array-first-vs-index.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#[0] 238.713M i/100ms
Array#first 238.574M i/100ms
Calculating -------------------------------------
Array#[0] 2.387B (± 0.3%) i/s - 11.936B in 5.000506s
Array#first 2.389B (± 0.2%) i/s - 12.167B in 5.093611s
Comparison:
Array#first: 2388745158.1 i/s
Array#[0]: 2386910075.9 i/s - same-ish: difference falls within error
$ ruby -v code/array/array-last-vs-index.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#[-1] 238.845M i/100ms
Array#last 238.833M i/100ms
Calculating -------------------------------------
Array#[-1] 2.385B (± 0.4%) i/s - 11.942B in 5.007831s
Array#last 2.389B (± 0.1%) i/s - 12.180B in 5.097897s
Comparison:
Array#last: 2389315297.0 i/s
Array#[-1]: 2384751491.8 i/s - same-ish: difference falls within error
$ ruby -v code/array/bsearch-vs-find.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
find 1.000 i/100ms
bsearch 488.867k i/100ms
Calculating -------------------------------------
find 6.512 (±30.7%) i/s - 12.000 in 5.056216s
bsearch 4.919M (± 3.0%) i/s - 24.932M in 5.073881s
Comparison:
bsearch: 4918578.4 i/s
find: 6.5 i/s - 755310.39x (± 0.00) slower
$ ruby -v code/array/insert-vs-unshift.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#unshift 1.000 i/100ms
Array#insert 1.000 i/100ms
Calculating -------------------------------------
Array#unshift 0.119 (± 0.0%) i/s - 1.000 in 8.431490s
Array#insert 0.945 (± 0.0%) i/s - 5.000 in 5.293181s
Comparison:
Array#insert: 0.9 i/s
Array#unshift: 0.1 i/s - 7.96x (± 0.00) slower
$ ruby -v code/array/length-vs-size-vs-count.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#length 238.420M i/100ms
Array#size 238.836M i/100ms
Array#count 239.083M i/100ms
Calculating -------------------------------------
Array#length 2.384B (± 0.5%) i/s - 11.921B in 5.000794s
Array#size 2.389B (± 0.2%) i/s - 12.181B in 5.098725s
Array#count 2.387B (± 0.5%) i/s - 11.954B in 5.008003s
Comparison:
Array#size: 2388967600.3 i/s
Array#count: 2387066466.5 i/s - same-ish: difference falls within error
Array#length: 2383888610.0 i/s - same-ish: difference falls within error
$ ruby -v code/array/shuffle-first-vs-sample.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#shuffle.first 23.263k i/100ms
Array#sample 2.544M i/100ms
Calculating -------------------------------------
Array#shuffle.first 236.181k (± 1.7%) i/s - 1.186M in 5.024975s
Array#sample 25.447M (± 0.1%) i/s - 129.762M in 5.099343s
Comparison:
Array#sample: 25446951.2 i/s
Array#shuffle.first: 236180.5 i/s - 107.74x (± 0.00) slower
$ ruby -v code/date/iso8601-vs-parse.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Date.iso8601 418.000 i/100ms
Date.parse 146.000 i/100ms
Calculating -------------------------------------
Date.iso8601 21.726k (±27.9%) i/s - 92.796k in 4.999351s
Date.parse 8.680k (±26.3%) i/s - 36.354k in 4.989446s
Comparison:
Date.iso8601: 21726.0 i/s
Date.parse: 8680.2 i/s - 2.50x (± 0.00) slower
$ ruby -v code/enumerable/each-push-vs-map.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#each + push 140.707k i/100ms
Array#map 496.920k i/100ms
Calculating -------------------------------------
Array#each + push 1.486M (± 3.8%) i/s - 7.457M in 5.026196s
Array#map 5.120M (± 6.9%) i/s - 25.840M in 5.070461s
Comparison:
Array#map: 5119724.5 i/s
Array#each + push: 1485972.7 i/s - 3.45x (± 0.00) slower
$ ruby -v code/enumerable/each-vs-for-loop.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
For loop 10.625M i/100ms
#each 56.622M i/100ms
Calculating -------------------------------------
For loop 105.619M (± 1.1%) i/s - 531.255M in 5.030577s
#each 568.877M (± 0.3%) i/s - 2.888B in 5.076238s
Comparison:
#each: 568876669.5 i/s
For loop: 105619003.3 i/s - 5.39x (± 0.00) slower
$ ruby -v code/enumerable/each_with_index-vs-while-loop.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
While Loop 901.103k i/100ms
each_with_index 1.280M i/100ms
Calculating -------------------------------------
While Loop 9.075M (± 0.2%) i/s - 45.956M in 5.063892s
each_with_index 12.824M (± 0.2%) i/s - 65.287M in 5.090847s
Comparison:
each_with_index: 12824412.8 i/s
While Loop: 9075334.7 i/s - 1.41x (± 0.00) slower
$ ruby -v code/enumerable/inject-symbol-vs-block.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
inject symbol 146.321k i/100ms
inject to_proc 147.473k i/100ms
inject block 147.501k i/100ms
Calculating -------------------------------------
inject symbol 1.473M (± 0.2%) i/s - 7.462M in 5.065087s
inject to_proc 1.474M (± 0.1%) i/s - 7.374M in 5.001076s
inject block 1.474M (± 0.2%) i/s - 7.375M in 5.002164s
Comparison:
inject to_proc: 1474415.8 i/s
inject block: 1474375.6 i/s - same-ish: difference falls within error
inject symbol: 1473303.5 i/s - same-ish: difference falls within error
$ ruby -v code/enumerable/map-flatten-vs-flat_map.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#map.flatten(1) 9.351k i/100ms
Array#map.flatten 10.565k i/100ms
Array#flat_map 30.485k i/100ms
Calculating -------------------------------------
Array#map.flatten(1) 107.278k (± 3.2%) i/s - 542.358k in 5.061326s
Array#map.flatten 106.870k (± 2.9%) i/s - 538.815k in 5.046344s
Array#flat_map 305.983k (± 2.7%) i/s - 1.555M in 5.085191s
Comparison:
Array#flat_map: 305982.7 i/s
Array#map.flatten(1): 107277.8 i/s - 2.85x (± 0.00) slower
Array#map.flatten: 106870.2 i/s - 2.86x (± 0.00) slower
$ ruby -v code/enumerable/reverse-each-vs-reverse_each.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#reverse.each 183.527k i/100ms
Array#reverse_each 1.953M i/100ms
Calculating -------------------------------------
Array#reverse.each 1.874M (± 3.2%) i/s - 9.543M in 5.098906s
Array#reverse_each 19.515M (± 0.2%) i/s - 97.626M in 5.002736s
Comparison:
Array#reverse_each: 19514597.7 i/s
Array#reverse.each: 1873695.3 i/s - 10.42x (± 0.00) slower
$ ruby -v code/enumerable/select-first-vs-detect.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#select.first
536.161k i/100ms
Enumerable#detect 3.831M i/100ms
Calculating -------------------------------------
Enumerable#select.first
6.012M (± 5.7%) i/s - 120.100M in 20.061809s
Enumerable#detect 38.290M (± 0.2%) i/s - 766.148M in 20.009148s
Comparison:
Enumerable#detect: 38290046.1 i/s
Enumerable#select.first: 6012354.7 i/s - 6.37x (± 0.00) slower
$ ruby -v code/enumerable/select-last-vs-reverse-detect.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#reverse.detect
187.912k i/100ms
Enumerable#select.last
375.959k i/100ms
Calculating -------------------------------------
Enumerable#reverse.detect
1.933M (± 3.4%) i/s - 9.771M in 5.061692s
Enumerable#select.last
3.792M (± 3.6%) i/s - 19.174M in 5.063959s
Comparison:
Enumerable#select.last: 3791616.8 i/s
Enumerable#reverse.detect: 1932845.1 i/s - 1.96x (± 0.00) slower
$ ruby -v code/enumerable/sort-vs-sort_by.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#sort_by (Symbol#to_proc)
2.283k i/100ms
Enumerable#sort_by 1.106k i/100ms
Enumerable#sort 3.066k i/100ms
Calculating -------------------------------------
Enumerable#sort_by (Symbol#to_proc)
22.790k (±12.7%) i/s - 114.150k in 5.095903s
Enumerable#sort_by 22.224k (±16.2%) i/s - 108.388k in 5.009623s
Enumerable#sort 32.905k (± 0.2%) i/s - 165.564k in 5.031610s
Comparison:
Enumerable#sort: 32904.9 i/s
Enumerable#sort_by (Symbol#to_proc): 22789.5 i/s - 1.44x (± 0.00) slower
Enumerable#sort_by: 22223.9 i/s - 1.48x (± 0.00) slower
$ ruby -v code/enumerable/sort_by-first-vs-min_by.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#min_by 460.378k i/100ms
Enumerable#sort_by...first
4.939k i/100ms
Calculating -------------------------------------
Enumerable#min_by 4.641M (± 0.3%) i/s - 23.479M in 5.058708s
Enumerable#sort_by...first
58.702k (± 3.0%) i/s - 296.340k in 5.053092s
Comparison:
Enumerable#min_by: 4641399.1 i/s
Enumerable#sort_by...first: 58701.6 i/s - 79.07x (± 0.00) slower
$ ruby -v code/hash/bracket-vs-dup.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash[] 171.864k i/100ms
Hash#dup 197.031k i/100ms
Calculating -------------------------------------
Hash[] 1.972M (± 4.1%) i/s - 9.968M in 5.064892s
Hash#dup 1.985M (± 3.4%) i/s - 10.049M in 5.068033s
Comparison:
Hash#dup: 1985172.2 i/s
Hash[]: 1971594.9 i/s - same-ish: difference falls within error
$ ruby -v code/hash/bracket-vs-fetch.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#[], symbol 238.408M i/100ms
Hash#fetch, symbol 238.338M i/100ms
Hash#[], string 2.570M i/100ms
Hash#fetch, string 2.656M i/100ms
Calculating -------------------------------------
Hash#[], symbol 2.387B (± 0.2%) i/s - 12.159B in 5.093189s
Hash#fetch, symbol 2.388B (± 0.2%) i/s - 12.155B in 5.089685s
Hash#[], string 129.777M (± 0.7%) i/s - 650.250M in 5.010781s
Hash#fetch, string 142.049M (± 0.5%) i/s - 711.858M in 5.011473s
Comparison:
Hash#fetch, symbol: 2388220505.8 i/s
Hash#[], symbol: 2387278462.1 i/s - same-ish: difference falls within error
Hash#fetch, string: 142048956.0 i/s - 16.81x (± 0.00) slower
Hash#[], string: 129777154.2 i/s - 18.40x (± 0.00) slower
$ ruby -v code/hash/dig-vs-[]-vs-fetch.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#dig 59.686M i/100ms
Hash#[] 59.681M i/100ms
Hash#[] || 59.678M i/100ms
Hash#[] && 59.738M i/100ms
Hash#fetch 59.755M i/100ms
Hash#fetch fallback 59.727M i/100ms
Calculating -------------------------------------
Hash#dig 596.852M (± 0.2%) i/s - 2.984B in 5.000080s
Hash#[] 597.097M (± 0.1%) i/s - 3.044B in 5.097579s
Hash#[] || 597.017M (± 0.2%) i/s - 3.044B in 5.097968s
Hash#[] && 596.802M (± 0.3%) i/s - 2.987B in 5.004845s
Hash#fetch 597.172M (± 0.2%) i/s - 2.988B in 5.003176s
Hash#fetch fallback 597.048M (± 0.2%) i/s - 2.986B in 5.001905s
Comparison:
Hash#fetch: 597172175.6 i/s
Hash#[]: 597097210.1 i/s - same-ish: difference falls within error
Hash#fetch fallback: 597047517.4 i/s - same-ish: difference falls within error
Hash#[] ||: 597016712.4 i/s - same-ish: difference falls within error
Hash#dig: 596852135.6 i/s - same-ish: difference falls within error
Hash#[] &&: 596801844.0 i/s - same-ish: difference falls within error
$ ruby -v code/hash/fetch-vs-fetch-with-block.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#fetch + const 238.387M i/100ms
Hash#fetch + block 238.562M i/100ms
Hash#fetch + arg 238.922M i/100ms
Calculating -------------------------------------
Hash#fetch + const 2.386B (± 0.3%) i/s - 12.158B in 5.095744s
Hash#fetch + block 2.389B (± 0.2%) i/s - 12.167B in 5.093049s
Hash#fetch + arg 2.389B (± 0.3%) i/s - 11.946B in 5.001456s
Comparison:
Hash#fetch + block: 2388882040.6 i/s
Hash#fetch + arg: 2388540951.3 i/s - same-ish: difference falls within error
Hash#fetch + const: 2385880386.6 i/s - same-ish: difference falls within error
$ ruby -v code/hash/hash-key-sort_by-vs-sort.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
sort_by + to_h 17.260k i/100ms
sort + to_h 6.294k i/100ms
Calculating -------------------------------------
sort_by + to_h 203.561k (± 7.7%) i/s - 1.018M in 5.033912s
sort + to_h 130.847k (± 4.8%) i/s - 654.576k in 5.015910s
Comparison:
sort_by + to_h: 203561.3 i/s
sort + to_h: 130847.3 i/s - 1.56x (± 0.00) slower
$ ruby -v code/hash/keys-each-vs-each_key.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#keys.each 150.282k i/100ms
Hash#each_key 166.589k i/100ms
Calculating -------------------------------------
Hash#keys.each 1.521M (±10.7%) i/s - 7.514M in 5.054162s
Hash#each_key 1.681M (± 3.1%) i/s - 8.496M in 5.057894s
Comparison:
Hash#each_key: 1681495.2 i/s
Hash#keys.each: 1520695.6 i/s - same-ish: difference falls within error
$ ruby -v code/hash/keys-include-vs-key.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#keys.include? 164.000 i/100ms
Hash#key? 2.503M i/100ms
Calculating -------------------------------------
Hash#keys.include? 1.917k (±14.0%) i/s - 9.348k in 5.040912s
Hash#key? 23.491M (± 1.0%) i/s - 117.660M in 5.009125s
Comparison:
Hash#key?: 23491171.1 i/s
Hash#keys.include?: 1917.3 i/s - 12252.43x (± 0.00) slower
$ ruby -v code/hash/merge-bang-vs-[]=.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#merge! 20.311k i/100ms
Hash#[]= 23.928k i/100ms
Calculating -------------------------------------
Hash#merge! 217.474k (± 9.4%) i/s - 1.076M in 5.046732s
Hash#[]= 240.881k (± 3.3%) i/s - 1.220M in 5.071773s
Comparison:
Hash#[]=: 240881.3 i/s
Hash#merge!: 217474.3 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-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
{}#merge!(Hash) do end
9.698k i/100ms
Hash#merge({}) 7.153k i/100ms
Hash#dup#merge!({}) 12.135k i/100ms
Calculating -------------------------------------
{}#merge!(Hash) do end
112.185k (± 3.9%) i/s - 562.484k in 5.022274s
Hash#merge({}) 73.302k (± 3.7%) i/s - 371.956k in 5.081947s
Hash#dup#merge!({}) 122.272k (± 3.5%) i/s - 618.885k in 5.068451s
Comparison:
Hash#dup#merge!({}): 122272.0 i/s
{}#merge!(Hash) do end: 112184.7 i/s - 1.09x (± 0.00) slower
Hash#merge({}): 73302.3 i/s - 1.67x (± 0.00) slower
$ ruby -v code/hash/merge-vs-double-splat-operator.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#**other 238.379M i/100ms
Hash#merge 239.077M i/100ms
Calculating -------------------------------------
Hash#**other 2.386B (± 0.3%) i/s - 12.157B in 5.095058s
Hash#merge 2.389B (± 0.2%) i/s - 11.954B in 5.003836s
Comparison:
Hash#merge: 2388949355.8 i/s
Hash#**other: 2386127172.2 i/s - same-ish: difference falls within error
$ ruby -v code/hash/merge-vs-merge-bang.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#merge 269.000 i/100ms
Hash#merge! 22.350k i/100ms
Calculating -------------------------------------
Hash#merge 3.054k (± 4.0%) i/s - 15.333k in 5.028872s
Hash#merge! 226.543k (± 3.4%) i/s - 1.140M in 5.037623s
Comparison:
Hash#merge!: 226543.4 i/s
Hash#merge: 3054.1 i/s - 74.18x (± 0.00) slower
$ ruby -v code/hash/slice-native-vs-before-native.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#native-slice 981.375k i/100ms
Array#each 955.582k i/100ms
Array#each_w/_object 950.534k i/100ms
Hash#select-include 1.301M i/100ms
Calculating -------------------------------------
Hash#native-slice 11.547M (± 4.4%) i/s - 57.901M in 5.025308s
Array#each 9.663M (± 3.2%) i/s - 48.735M in 5.048993s
Array#each_w/_object 9.591M (± 3.3%) i/s - 48.477M in 5.060665s
Hash#select-include 13.050M (± 3.2%) i/s - 66.328M in 5.088235s
Comparison:
Hash#select-include : 13050396.0 i/s
Hash#native-slice : 11546586.6 i/s - 1.13x (± 0.00) slower
Array#each : 9663265.1 i/s - 1.35x (± 0.00) slower
Array#each_w/_object: 9590910.3 i/s - 1.36x (± 0.00) slower
$ ruby -v code/hash/values-include-vs-value.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#values.include? 195.000 i/100ms
Hash#value? 721.000 i/100ms
Calculating -------------------------------------
Hash#values.include? 2.060k (±13.0%) i/s - 10.140k in 5.066054s
Hash#value? 7.349k (± 0.2%) i/s - 36.771k in 5.003507s
Comparison:
Hash#value?: 7349.1 i/s
Hash#values.include?: 2059.5 i/s - 3.57x (± 0.00) slower
$ ruby -v code/method/call-vs-send-vs-method_missing.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
call 238.416M i/100ms
send 238.325M i/100ms
method_missing 239.008M i/100ms
Calculating -------------------------------------
call 2.387B (± 0.3%) i/s - 12.159B in 5.094790s
send 2.385B (± 0.7%) i/s - 12.155B in 5.096670s
method_missing 2.388B (± 0.2%) i/s - 11.950B in 5.004013s
Comparison:
method_missing: 2388172111.5 i/s
call: 2386618019.6 i/s - same-ish: difference falls within error
send: 2384912726.8 i/s - same-ish: difference falls within error
$ ruby -v code/proc-and-block/block-vs-to_proc.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Block 10.914k i/100ms
Symbol#to_proc 13.639k i/100ms
Calculating -------------------------------------
Block 137.671k (± 3.9%) i/s - 698.496k in 5.082068s
Symbol#to_proc 137.959k (± 3.1%) i/s - 695.589k in 5.047153s
Comparison:
Symbol#to_proc: 137958.7 i/s
Block: 137671.2 i/s - same-ish: difference falls within error
$ ruby -v code/proc-and-block/proc-call-vs-yield.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
block.call 238.364M i/100ms
block + yield 238.624M i/100ms
unused block 238.963M i/100ms
yield 238.822M i/100ms
Calculating -------------------------------------
block.call 2.387B (± 0.3%) i/s - 12.157B in 5.093621s
block + yield 2.389B (± 0.1%) i/s - 12.170B in 5.093354s
unused block 2.389B (± 0.2%) i/s - 11.948B in 5.001090s
yield 2.388B (± 0.2%) i/s - 12.180B in 5.099549s
Comparison:
block + yield: 2389350391.3 i/s
unused block: 2389115174.4 i/s - same-ish: difference falls within error
yield: 2388439389.6 i/s - same-ish: difference falls within error
block.call: 2386643741.6 i/s - same-ish: difference falls within error
$ ruby -v code/range/cover-vs-include.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
range#cover? 17.754k i/100ms
range#include? 171.000 i/100ms
range#member? 514.000 i/100ms
plain compare 12.322k i/100ms
Calculating -------------------------------------
range#cover? 86.793k (±32.0%) i/s - 390.588k in 5.047577s
range#include? 4.984k (±37.0%) i/s - 21.546k in 5.021074s
range#member? 4.671k (±21.3%) i/s - 22.616k in 5.078004s
plain compare 154.697k (±23.6%) i/s - 751.642k in 5.110905s
Comparison:
plain compare: 154696.9 i/s
range#cover?: 86792.6 i/s - 1.78x (± 0.00) slower
range#include?: 4983.6 i/s - 31.04x (± 0.00) slower
range#member?: 4671.1 i/s - 33.12x (± 0.00) slower
$ ruby -v code/string/===-vs-=~-vs-match.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#match? 12.859M i/100ms
String#=~ 11.064M i/100ms
Regexp#=== 11.062M i/100ms
String#match 6.637M i/100ms
Calculating -------------------------------------
String#match? 129.770M (± 0.2%) i/s - 655.827M in 5.053792s
String#=~ 110.635M (± 0.1%) i/s - 553.202M in 5.000249s
Regexp#=== 110.618M (± 0.1%) i/s - 553.100M in 5.000084s
String#match 66.366M (± 0.1%) i/s - 331.873M in 5.000683s
Comparison:
String#match?: 129770064.5 i/s
String#=~: 110635056.5 i/s - 1.17x (± 0.00) slower
Regexp#===: 110618265.3 i/s - 1.17x (± 0.00) slower
String#match: 66365627.0 i/s - 1.96x (± 0.00) slower
$ ruby -v code/string/casecmp-vs-downcase-==.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#downcase + == 1.253M i/100ms
String#casecmp 2.385M i/100ms
Calculating -------------------------------------
String#downcase + == 14.603M (± 4.5%) i/s - 73.917M in 5.072388s
String#casecmp 24.339M (± 3.1%) i/s - 121.634M in 5.002718s
Comparison:
String#casecmp: 24338702.3 i/s
String#downcase + ==: 14603360.1 i/s - 1.67x (± 0.00) slower
$ ruby -v code/string/concatenation.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#+ 5.802M i/100ms
String#concat 7.529M i/100ms
String#append 7.510M i/100ms
"foo" "bar" 239.069M i/100ms
"#{'foo'}#{'bar'}" 239.090M i/100ms
Calculating -------------------------------------
String#+ 75.910M (± 4.6%) i/s - 382.901M in 5.055554s
String#concat 73.894M (± 3.8%) i/s - 368.916M in 5.000018s
String#append 75.820M (± 4.4%) i/s - 382.989M in 5.061660s
"foo" "bar" 2.389B (± 0.2%) i/s - 11.953B in 5.003543s
"#{'foo'}#{'bar'}" 2.389B (± 0.2%) i/s - 11.954B in 5.004036s
Comparison:
"foo" "bar": 2389006065.8 i/s
"#{'foo'}#{'bar'}": 2388975903.1 i/s - same-ish: difference falls within error
String#+: 75910479.7 i/s - 31.47x (± 0.00) slower
String#append: 75819772.1 i/s - 31.51x (± 0.00) slower
String#concat: 73894383.2 i/s - 32.33x (± 0.00) slower
$ ruby -v code/string/dup-vs-unary-plus.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#+@ 238.688M i/100ms
String#dup 238.815M i/100ms
Calculating -------------------------------------
String#+@ 2.387B (± 0.3%) i/s - 11.934B in 5.000644s
String#dup 2.389B (± 0.2%) i/s - 12.180B in 5.098528s
Comparison:
String#dup: 2388848190.8 i/s
String#+@: 2386595875.1 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-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#=~ 1.145M i/100ms
String#match? 1.603M i/100ms
String#end_with? 8.278M i/100ms
Calculating -------------------------------------
String#=~ 11.638M (± 2.7%) i/s - 58.412M in 5.022933s
String#match? 16.071M (± 0.4%) i/s - 81.729M in 5.085685s
String#end_with? 82.755M (± 0.3%) i/s - 413.915M in 5.001742s
Comparison:
String#end_with?: 82755145.0 i/s
String#match?: 16070628.2 i/s - 5.15x (± 0.00) slower
String#=~: 11638163.1 i/s - 7.11x (± 0.00) slower
$ ruby -v code/string/gsub-vs-sub.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#gsub 245.356k i/100ms
String#sub 332.616k i/100ms
String#dup["string"]=
9.639M i/100ms
Calculating -------------------------------------
String#gsub 3.210M (± 6.5%) i/s - 16.193M in 5.069848s
String#sub 4.728M (± 8.0%) i/s - 23.616M in 5.032323s
String#dup["string"]=
96.302M (± 0.4%) i/s - 481.955M in 5.004708s
Comparison:
String#dup["string"]=: 96301596.6 i/s
String#sub: 4728115.4 i/s - 20.37x (± 0.00) slower
String#gsub: 3209686.1 i/s - 30.00x (± 0.00) slower
$ ruby -v code/string/gsub-vs-tr.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#gsub 108.077k i/100ms
String#tr 83.296k i/100ms
Calculating -------------------------------------
String#gsub 1.788M (± 5.9%) i/s - 8.970M in 5.037701s
String#tr 838.369k (± 3.9%) i/s - 4.248M in 5.075299s
Comparison:
String#gsub: 1787504.7 i/s
String#tr: 838368.6 i/s - 2.13x (± 0.00) slower
$ ruby -v code/string/mutable_vs_immutable_strings.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Without Freeze 238.465M i/100ms
With Freeze 238.838M i/100ms
Calculating -------------------------------------
Without Freeze 2.387B (± 0.3%) i/s - 12.162B in 5.095776s
With Freeze 2.387B (± 0.6%) i/s - 11.942B in 5.003026s
Comparison:
With Freeze: 2387022894.7 i/s
Without Freeze: 2386651462.8 i/s - same-ish: difference falls within error
$ ruby -v code/string/remove-extra-spaces-or-other-chars.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#gsub/regex+/ 4.330k i/100ms
String#squeeze 27.229k i/100ms
Calculating -------------------------------------
String#gsub/regex+/ 54.096k (± 4.2%) i/s - 272.790k in 5.051942s
String#squeeze 273.287k (± 1.9%) i/s - 1.389M in 5.083515s
Comparison:
String#squeeze: 273286.8 i/s
String#gsub/regex+/: 54096.1 i/s - 5.05x (± 0.00) slower
$ ruby -v code/string/start-string-checking-match-vs-start_with.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#=~ 2.331M i/100ms
String#match? 3.842M i/100ms
String#start_with? 14.938M i/100ms
Calculating -------------------------------------
String#=~ 23.520M (± 3.2%) i/s - 118.904M in 5.061009s
String#match? 38.192M (± 0.7%) i/s - 192.086M in 5.029709s
String#start_with? 149.225M (± 0.3%) i/s - 746.886M in 5.005134s
Comparison:
String#start_with?: 149225064.9 i/s
String#match?: 38192130.8 i/s - 3.91x (± 0.00) slower
String#=~: 23519937.4 i/s - 6.34x (± 0.00) slower
$ ruby -v code/string/start_with-vs-substring-==.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#start_with? 93.262k i/100ms
String#[0, n] == 198.094k i/100ms
String#[RANGE] == 303.317k i/100ms
String#[0...n] == 167.730k i/100ms
Calculating -------------------------------------
String#start_with? 4.113M (± 0.4%) i/s - 20.611M in 5.011568s
String#[0, n] == 2.044M (± 3.5%) i/s - 10.301M in 5.046593s
String#[RANGE] == 3.021M (± 3.2%) i/s - 15.166M in 5.026079s
String#[0...n] == 1.701M (± 3.3%) i/s - 8.554M in 5.035214s
Comparison:
String#start_with?: 4112720.2 i/s
String#[RANGE] ==: 3020888.2 i/s - 1.36x (± 0.00) slower
String#[0, n] ==: 2043898.9 i/s - 2.01x (± 0.00) slower
String#[0...n] ==: 1700931.8 i/s - 2.42x (± 0.00) slower
$ ruby -v code/string/sub!-vs-gsub!-vs-[]=.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#['string']= 9.627M i/100ms
String#sub!'string' 279.343k i/100ms
String#gsub!'string' 389.688k i/100ms
String#[/regexp/]= 1.134M i/100ms
String#sub!/regexp/ 1.413M i/100ms
String#gsub!/regexp/ 407.782k i/100ms
Calculating -------------------------------------
String#['string']= 96.331M (± 0.1%) i/s - 490.987M in 5.096862s
String#sub!'string' 4.771M (±12.6%) i/s - 22.627M in 5.045365s
String#gsub!'string' 4.043M (± 4.4%) i/s - 20.264M in 5.022523s
String#[/regexp/]= 11.329M (± 2.4%) i/s - 56.683M in 5.006368s
String#sub!/regexp/ 14.206M (± 1.9%) i/s - 72.075M in 5.075411s
String#gsub!/regexp/ 4.072M (± 4.4%) i/s - 20.389M in 5.017297s
Comparison:
String#['string']=: 96331223.8 i/s
String#sub!/regexp/: 14206174.9 i/s - 6.78x (± 0.00) slower
String#[/regexp/]=: 11328954.0 i/s - 8.50x (± 0.00) slower
String#sub!'string': 4770560.0 i/s - 20.19x (± 0.00) slower
String#gsub!/regexp/: 4072071.1 i/s - 23.66x (± 0.00) slower
String#gsub!'string': 4043093.8 i/s - 23.83x (± 0.00) slower
$ ruby -v code/string/sub-vs-chomp-vs-delete_suffix.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#sub 1.636M i/100ms
String#chomp 3.776M i/100ms
String#delete_suffix 3.935M i/100ms
Calculating -------------------------------------
String#sub 16.843M (± 2.6%) i/s - 85.096M in 5.055881s
String#chomp 37.737M (± 0.8%) i/s - 188.821M in 5.003964s
String#delete_suffix 39.692M (± 3.2%) i/s - 200.694M in 5.061659s
Comparison:
String#delete_suffix: 39692207.6 i/s
String#chomp: 37736908.6 i/s - 1.05x (± 0.00) slower
String#sub: 16843417.1 i/s - 2.36x (± 0.00) slower
$ ruby -v code/string/sub-vs-delete_prefix.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#delete_prefix 238.550M i/100ms
String#sub 11.062M i/100ms
Calculating -------------------------------------
String#delete_prefix 2.387B (± 0.2%) i/s - 12.166B in 5.096165s
String#sub 110.546M (± 0.3%) i/s - 553.105M in 5.003434s
Comparison:
String#delete_prefix: 2387310490.4 i/s
String#sub: 110545796.6 i/s - 21.60x (± 0.00) slower
$ ruby -v code/string/unpack1-vs-unpack[0].rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#unpack1 969.148k i/100ms
String#unpack[0] 1.065M i/100ms
Calculating -------------------------------------
String#unpack1 10.829M (± 4.0%) i/s - 54.272M in 5.020203s
String#unpack[0] 10.820M (± 3.5%) i/s - 54.302M in 5.025097s
Comparison:
String#unpack1: 10829291.7 i/s
String#unpack[0]: 10819951.2 i/s - same-ish: difference falls within error
$ ruby -v code/time/iso8601-vs-parse.rb
truffleruby 23.0.0-dev-bacad37e, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Time.iso8601 15.520k i/100ms
Time.parse 184.000 i/100ms
Calculating -------------------------------------
Time.iso8601 219.205k (±31.5%) i/s - 962.240k in 5.018420s
Time.parse 6.618k (±29.3%) i/s - 27.600k in 5.005541s
Comparison:
Time.iso8601: 219205.1 i/s
Time.parse: 6618.1 i/s - 33.12x (± 0.00) slower