forked from fastruby/fast-ruby
-
Notifications
You must be signed in to change notification settings - Fork 1
/
runs.log
922 lines (800 loc) · 41.9 KB
/
runs.log
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-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Function with single Array argument
200.447M i/100ms
Function with splat arguments
611.000 i/100ms
Calculating -------------------------------------
Function with single Array argument
2.028B (± 1.4%) i/s - 10.223B in 5.042922s
Function with splat arguments
6.442k (± 6.2%) i/s - 32.383k in 5.047986s
Comparison:
Function with single Array argument: 2027536875.6 i/s
Function with splat arguments: 6441.9 i/s - 314740.29x (± 0.00) slower
$ ruby -v code/general/assignment.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Parallel Assignment 200.358M i/100ms
Sequential Assignment
195.183M i/100ms
Calculating -------------------------------------
Parallel Assignment 2.023B (± 1.2%) i/s - 10.218B in 5.050776s
Sequential Assignment
2.030B (± 1.3%) i/s - 10.150B in 5.001738s
Comparison:
Sequential Assignment: 2029519253.0 i/s
Parallel Assignment: 2023397334.6 i/s - same-ish: difference falls within error
$ ruby -v code/general/attr-accessor-vs-getter-and-setter.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
getter_and_setter 201.848M i/100ms
attr_accessor 201.615M i/100ms
Calculating -------------------------------------
getter_and_setter 2.014B (± 0.9%) i/s - 10.092B in 5.012106s
attr_accessor 2.028B (± 1.4%) i/s - 10.282B in 5.071012s
Comparison:
attr_accessor: 2028086287.0 i/s
getter_and_setter: 2013751689.5 i/s - same-ish: difference falls within error
$ ruby -v code/general/begin-rescue-vs-respond-to.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
begin...rescue 7.493k i/100ms
respond_to? 200.589M i/100ms
Calculating -------------------------------------
begin...rescue 49.886k (± 3.3%) i/s - 254.762k in 5.112556s
respond_to? 2.012B (± 0.8%) i/s - 10.230B in 5.084869s
Comparison:
respond_to?: 2011987389.2 i/s
begin...rescue: 49886.5 i/s - 40331.33x (± 0.00) slower
$ ruby -v code/general/block-apply-method.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
normal 200.066M i/100ms
&method 200.236M i/100ms
Calculating -------------------------------------
normal 2.016B (± 1.6%) i/s - 10.203B in 5.061952s
&method 2.024B (± 1.0%) i/s - 10.212B in 5.044875s
Comparison:
&method: 2024438381.5 i/s
normal: 2016232613.4 i/s - same-ish: difference falls within error
$ ruby -v code/general/define_method-vs-module-eval.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
module_eval with string
94.000 i/100ms
define_method 122.000 i/100ms
Calculating -------------------------------------
module_eval with string
1.422k (±50.3%) i/s - 4.324k in 5.024108s
define_method 3.120k (±60.7%) i/s - 5.978k in 6.485493s
Comparison:
define_method: 3119.9 i/s
module_eval with string: 1421.9 i/s - same-ish: difference falls within error
$ ruby -v code/general/format-vs-round-and-to-s.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Float#round 63.299k i/100ms
Kernel#format 55.666k i/100ms
String#% 57.183k i/100ms
Calculating -------------------------------------
Float#round 668.555k (± 3.2%) i/s - 3.355M in 5.023285s
Kernel#format 574.490k (± 2.8%) i/s - 2.895M in 5.042761s
String#% 568.729k (± 2.6%) i/s - 2.859M in 5.030821s
Comparison:
Float#round: 668554.9 i/s
Kernel#format: 574490.2 i/s - 1.16x (± 0.00) slower
String#%: 568729.3 i/s - 1.18x (± 0.00) slower
$ ruby -v code/general/hash-vs-openstruct-on-access.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash 199.395M i/100ms
OpenStruct 196.379M i/100ms
Calculating -------------------------------------
Hash 2.001B (± 0.7%) i/s - 10.169B in 5.081972s
OpenStruct 2.000B (± 2.0%) i/s - 10.015B in 5.010621s
Comparison:
Hash: 2001123154.7 i/s
OpenStruct: 1999685565.5 i/s - same-ish: difference falls within error
$ ruby -v code/general/hash-vs-openstruct.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash 200.259M i/100ms
OpenStruct 2.518k i/100ms
Calculating -------------------------------------
Hash 2.040B (± 1.9%) i/s - 10.213B in 5.007078s
OpenStruct 27.796k (±13.3%) i/s - 135.972k in 5.038488s
Comparison:
Hash: 2040452782.4 i/s
OpenStruct: 27795.7 i/s - 73408.94x (± 0.00) slower
$ ruby -v code/general/inheritance-check.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
less than or equal 676.413k i/100ms
ancestors.include? 122.752k i/100ms
Calculating -------------------------------------
less than or equal 7.469M (± 4.2%) i/s - 37.879M in 5.080778s
ancestors.include? 1.215M (± 4.3%) i/s - 6.138M in 5.061061s
Comparison:
less than or equal: 7468964.2 i/s
ancestors.include?: 1215047.5 i/s - 6.15x (± 0.00) slower
$ ruby -v code/general/loop-vs-while-true.rb
truffleruby 23.0.0-dev-33ae0fe4, 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 20.572 (± 4.9%) i/s - 103.000 in 5.010015s
Kernel loop 20.559 (± 0.0%) i/s - 103.000 in 5.012031s
Comparison:
While Loop: 20.6 i/s
Kernel loop: 20.6 i/s - same-ish: difference falls within error
$ ruby -v code/general/raise-vs-e2mmap.rb
truffleruby 23.0.0-dev-33ae0fe4, 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-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#[0] 201.336M i/100ms
Array#first 203.400M i/100ms
Calculating -------------------------------------
Array#[0] 2.050B (± 1.6%) i/s - 10.268B in 5.009659s
Array#first 2.051B (± 1.9%) i/s - 10.373B in 5.058426s
Comparison:
Array#first: 2051416996.8 i/s
Array#[0]: 2050222389.2 i/s - same-ish: difference falls within error
$ ruby -v code/array/array-last-vs-index.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#[-1] 201.824M i/100ms
Array#last 200.624M i/100ms
Calculating -------------------------------------
Array#[-1] 2.013B (± 0.9%) i/s - 10.091B in 5.013522s
Array#last 2.019B (± 0.8%) i/s - 10.232B in 5.068411s
Comparison:
Array#last: 2018892176.0 i/s
Array#[-1]: 2012963348.9 i/s - same-ish: difference falls within error
$ ruby -v code/array/bsearch-vs-find.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
find 1.000 i/100ms
bsearch 445.083k i/100ms
Calculating -------------------------------------
find 5.871 (±34.1%) i/s - 11.000 in 5.103458s
bsearch 4.486M (± 4.5%) i/s - 22.699M in 5.070140s
Comparison:
bsearch: 4486414.2 i/s
find: 5.9 i/s - 764170.07x (± 0.00) slower
$ ruby -v code/array/insert-vs-unshift.rb
truffleruby 23.0.0-dev-33ae0fe4, 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.107 (± 0.0%) i/s - 1.000 in 9.325862s
Array#insert 0.801 (± 0.0%) i/s - 5.000 in 6.241771s
Comparison:
Array#insert: 0.8 i/s
Array#unshift: 0.1 i/s - 7.47x (± 0.00) slower
$ ruby -v code/array/length-vs-size-vs-count.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#length 201.476M i/100ms
Array#size 205.525M i/100ms
Array#count 205.972M i/100ms
Calculating -------------------------------------
Array#length 2.046B (± 2.6%) i/s - 10.275B in 5.026503s
Array#size 2.031B (± 1.7%) i/s - 10.276B in 5.062419s
Array#count 2.005B (± 1.1%) i/s - 10.093B in 5.034491s
Comparison:
Array#length: 2045637740.0 i/s
Array#size: 2030513044.1 i/s - same-ish: difference falls within error
Array#count: 2004926054.3 i/s - same-ish: difference falls within error
$ ruby -v code/array/shuffle-first-vs-sample.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#shuffle.first 18.962k i/100ms
Array#sample 2.184M i/100ms
Calculating -------------------------------------
Array#shuffle.first 204.147k (± 2.1%) i/s - 1.024M in 5.018107s
Array#sample 21.773M (± 0.7%) i/s - 109.217M in 5.016475s
Comparison:
Array#sample: 21772753.8 i/s
Array#shuffle.first: 204147.1 i/s - 106.65x (± 0.00) slower
$ ruby -v code/date/iso8601-vs-parse.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Date.iso8601 388.000 i/100ms
Date.parse 103.000 i/100ms
Calculating -------------------------------------
Date.iso8601 15.483k (±31.6%) i/s - 65.572k in 5.007007s
Date.parse 7.469k (±30.4%) i/s - 30.076k in 4.997556s
Comparison:
Date.iso8601: 15482.8 i/s
Date.parse: 7469.1 i/s - 2.07x (± 0.00) slower
$ ruby -v code/enumerable/each-push-vs-map.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#each + push 138.569k i/100ms
Array#map 517.293k i/100ms
Calculating -------------------------------------
Array#each + push 1.445M (± 3.6%) i/s - 7.344M in 5.087789s
Array#map 5.154M (± 6.8%) i/s - 25.865M in 5.042669s
Comparison:
Array#map: 5153882.0 i/s
Array#each + push: 1445489.2 i/s - 3.57x (± 0.00) slower
$ ruby -v code/enumerable/each-vs-for-loop.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
For loop 9.161M i/100ms
#each 49.401M i/100ms
Calculating -------------------------------------
For loop 91.157M (± 1.9%) i/s - 458.031M in 5.026490s
#each 490.642M (± 2.0%) i/s - 2.470B in 5.036464s
Comparison:
#each: 490641549.0 i/s
For loop: 91156559.7 i/s - 5.38x (± 0.00) slower
$ ruby -v code/enumerable/each_with_index-vs-while-loop.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
While Loop 776.237k i/100ms
each_with_index 1.114M i/100ms
Calculating -------------------------------------
While Loop 7.774M (± 1.7%) i/s - 39.588M in 5.093473s
each_with_index 11.060M (± 1.7%) i/s - 55.713M in 5.038721s
Comparison:
each_with_index: 11060283.0 i/s
While Loop: 7774439.7 i/s - 1.42x (± 0.00) slower
$ ruby -v code/enumerable/inject-symbol-vs-block.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
inject symbol 125.515k i/100ms
inject to_proc 125.299k i/100ms
inject block 123.704k i/100ms
Calculating -------------------------------------
inject symbol 1.271M (± 1.7%) i/s - 6.401M in 5.039672s
inject to_proc 1.268M (± 1.5%) i/s - 6.390M in 5.041851s
inject block 1.275M (± 1.6%) i/s - 6.433M in 5.047845s
Comparison:
inject block: 1274670.3 i/s
inject symbol: 1270552.4 i/s - same-ish: difference falls within error
inject to_proc: 1267737.8 i/s - same-ish: difference falls within error
$ ruby -v code/enumerable/map-flatten-vs-flat_map.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#map.flatten(1) 9.261k i/100ms
Array#map.flatten 10.585k i/100ms
Array#flat_map 27.447k i/100ms
Calculating -------------------------------------
Array#map.flatten(1) 105.498k (± 4.3%) i/s - 527.877k in 5.013621s
Array#map.flatten 105.563k (± 3.8%) i/s - 529.250k in 5.021562s
Array#flat_map 274.421k (± 3.2%) i/s - 1.372M in 5.006412s
Comparison:
Array#flat_map: 274420.9 i/s
Array#map.flatten: 105563.2 i/s - 2.60x (± 0.00) slower
Array#map.flatten(1): 105498.2 i/s - 2.60x (± 0.00) slower
$ ruby -v code/enumerable/reverse-each-vs-reverse_each.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Array#reverse.each 160.211k i/100ms
Array#reverse_each 1.683M i/100ms
Calculating -------------------------------------
Array#reverse.each 1.692M (± 3.4%) i/s - 8.491M in 5.025633s
Array#reverse_each 16.751M (± 1.6%) i/s - 84.134M in 5.023885s
Comparison:
Array#reverse_each: 16751082.9 i/s
Array#reverse.each: 1691625.2 i/s - 9.90x (± 0.00) slower
$ ruby -v code/enumerable/select-first-vs-detect.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#select.first
537.349k i/100ms
Enumerable#detect 3.315M i/100ms
Calculating -------------------------------------
Enumerable#select.first
5.949M (± 6.6%) i/s - 118.754M in 20.076984s
Enumerable#detect 33.097M (± 1.8%) i/s - 662.986M in 20.037739s
Comparison:
Enumerable#detect: 33097458.1 i/s
Enumerable#select.first: 5948994.5 i/s - 5.56x (± 0.00) slower
$ ruby -v code/enumerable/select-last-vs-reverse-detect.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#reverse.detect
150.144k i/100ms
Enumerable#select.last
340.028k i/100ms
Calculating -------------------------------------
Enumerable#reverse.detect
1.704M (± 4.0%) i/s - 8.558M in 5.030844s
Enumerable#select.last
3.433M (± 4.5%) i/s - 17.341M in 5.061748s
Comparison:
Enumerable#select.last: 3432997.5 i/s
Enumerable#reverse.detect: 1703973.5 i/s - 2.01x (± 0.00) slower
$ ruby -v code/enumerable/sort-vs-sort_by.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#sort_by (Symbol#to_proc)
1.982k i/100ms
Enumerable#sort_by 2.212k i/100ms
Enumerable#sort 123.000 i/100ms
Calculating -------------------------------------
Enumerable#sort_by (Symbol#to_proc)
19.947k (±10.9%) i/s - 99.100k in 5.029165s
Enumerable#sort_by 22.003k (± 8.0%) i/s - 110.600k in 5.069198s
Enumerable#sort 27.912k (± 2.7%) i/s - 139.482k in 5.000597s
Comparison:
Enumerable#sort: 27912.1 i/s
Enumerable#sort_by: 22003.0 i/s - 1.27x (± 0.00) slower
Enumerable#sort_by (Symbol#to_proc): 19946.6 i/s - 1.40x (± 0.00) slower
$ ruby -v code/enumerable/sort_by-first-vs-min_by.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Enumerable#min_by 390.750k i/100ms
Enumerable#sort_by...first
4.242k i/100ms
Calculating -------------------------------------
Enumerable#min_by 4.020M (± 2.0%) i/s - 20.319M in 5.056965s
Enumerable#sort_by...first
56.171k (± 4.2%) i/s - 284.214k in 5.069080s
Comparison:
Enumerable#min_by: 4019565.5 i/s
Enumerable#sort_by...first: 56171.0 i/s - 71.56x (± 0.00) slower
$ ruby -v code/hash/bracket-vs-dup.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash[] 168.414k i/100ms
Hash#dup 207.349k i/100ms
Calculating -------------------------------------
Hash[] 2.056M (± 5.2%) i/s - 10.273M in 5.010645s
Hash#dup 2.062M (± 5.2%) i/s - 10.367M in 5.043787s
Comparison:
Hash#dup: 2061704.6 i/s
Hash[]: 2056399.1 i/s - same-ish: difference falls within error
$ ruby -v code/hash/bracket-vs-fetch.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#[], symbol 199.143M i/100ms
Hash#fetch, symbol 201.638M i/100ms
Hash#[], string 2.341M i/100ms
Hash#fetch, string 2.481M i/100ms
Calculating -------------------------------------
Hash#[], symbol 2.062B (± 2.0%) i/s - 10.355B in 5.023793s
Hash#fetch, symbol 2.055B (± 2.1%) i/s - 10.284B in 5.006172s
Hash#[], string 112.345M (± 2.9%) i/s - 561.877M in 5.005555s
Hash#fetch, string 123.280M (± 3.3%) i/s - 617.690M in 5.015760s
Comparison:
Hash#[], symbol: 2062122059.6 i/s
Hash#fetch, symbol: 2055107311.6 i/s - same-ish: difference falls within error
Hash#fetch, string: 123279876.9 i/s - 16.73x (± 0.00) slower
Hash#[], string: 112344866.5 i/s - 18.36x (± 0.00) slower
$ ruby -v code/hash/dig-vs-[]-vs-fetch.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#dig 51.745M i/100ms
Hash#[] 51.082M i/100ms
Hash#[] || 52.354M i/100ms
Hash#[] && 52.227M i/100ms
Hash#fetch 51.822M i/100ms
Hash#fetch fallback 51.165M i/100ms
Calculating -------------------------------------
Hash#dig 512.332M (± 1.9%) i/s - 2.587B in 5.051728s
Hash#[] 516.995M (± 1.8%) i/s - 2.605B in 5.040663s
Hash#[] || 515.733M (± 1.8%) i/s - 2.618B in 5.077332s
Hash#[] && 511.677M (± 1.6%) i/s - 2.559B in 5.002749s
Hash#fetch 512.520M (± 1.8%) i/s - 2.591B in 5.057307s
Hash#fetch fallback 511.720M (± 2.0%) i/s - 2.558B in 5.001351s
Comparison:
Hash#[]: 516995402.8 i/s
Hash#[] ||: 515732879.8 i/s - same-ish: difference falls within error
Hash#fetch: 512520341.5 i/s - same-ish: difference falls within error
Hash#dig: 512331797.0 i/s - same-ish: difference falls within error
Hash#fetch fallback: 511720163.4 i/s - same-ish: difference falls within error
Hash#[] &&: 511676895.3 i/s - same-ish: difference falls within error
$ ruby -v code/hash/fetch-vs-fetch-with-block.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#fetch + const 201.030M i/100ms
Hash#fetch + block 200.884M i/100ms
Hash#fetch + arg 203.540M i/100ms
Calculating -------------------------------------
Hash#fetch + const 2.013B (± 1.6%) i/s - 10.253B in 5.094269s
Hash#fetch + block 2.032B (± 1.1%) i/s - 10.245B in 5.041911s
Hash#fetch + arg 2.034B (± 1.1%) i/s - 10.177B in 5.003500s
Comparison:
Hash#fetch + arg: 2034200482.4 i/s
Hash#fetch + block: 2032252730.5 i/s - same-ish: difference falls within error
Hash#fetch + const: 2013098903.9 i/s - same-ish: difference falls within error
$ ruby -v code/hash/hash-key-sort_by-vs-sort.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
sort_by + to_h 15.442k i/100ms
sort + to_h 307.000 i/100ms
Calculating -------------------------------------
sort_by + to_h 238.150k (± 5.4%) i/s - 1.189M in 5.011394s
sort + to_h 120.858k (±12.2%) i/s - 572.862k in 4.994102s
Comparison:
sort_by + to_h: 238150.0 i/s
sort + to_h: 120857.9 i/s - 1.97x (± 0.00) slower
$ ruby -v code/hash/keys-each-vs-each_key.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#keys.each 118.378k i/100ms
Hash#each_key 144.997k i/100ms
Calculating -------------------------------------
Hash#keys.each 1.313M (±10.6%) i/s - 6.511M in 5.078657s
Hash#each_key 1.475M (± 3.5%) i/s - 7.395M in 5.018819s
Comparison:
Hash#each_key: 1475345.7 i/s
Hash#keys.each: 1313153.5 i/s - same-ish: difference falls within error
$ ruby -v code/hash/keys-include-vs-key.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#keys.include? 161.000 i/100ms
Hash#key? 10.104M i/100ms
Calculating -------------------------------------
Hash#keys.include? 1.613k (± 8.8%) i/s - 8.050k in 5.036975s
Hash#key? 101.201M (± 1.2%) i/s - 515.302M in 5.092580s
Comparison:
Hash#key?: 101201119.6 i/s
Hash#keys.include?: 1613.4 i/s - 62724.77x (± 0.00) slower
$ ruby -v code/hash/merge-bang-vs-[]=.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#merge! 19.149k i/100ms
Hash#[]= 23.597k i/100ms
Calculating -------------------------------------
Hash#merge! 207.681k (±10.1%) i/s - 1.015M in 5.005838s
Hash#[]= 238.634k (± 4.1%) i/s - 1.203M in 5.051951s
Comparison:
Hash#[]=: 238634.3 i/s
Hash#merge!: 207681.2 i/s - 1.15x (± 0.00) slower
$ ruby -v code/hash/merge-bang-vs-merge-vs-dup-merge-bang.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
{}#merge!(Hash) do end
9.613k i/100ms
Hash#merge({}) 7.632k i/100ms
Hash#dup#merge!({}) 12.523k i/100ms
Calculating -------------------------------------
{}#merge!(Hash) do end
120.222k (± 5.5%) i/s - 605.619k in 5.054831s
Hash#merge({}) 77.933k (± 4.9%) i/s - 389.232k in 5.007644s
Hash#dup#merge!({}) 127.434k (± 4.3%) i/s - 638.673k in 5.022208s
Comparison:
Hash#dup#merge!({}): 127433.6 i/s
{}#merge!(Hash) do end: 120222.0 i/s - same-ish: difference falls within error
Hash#merge({}): 77933.0 i/s - 1.64x (± 0.00) slower
$ ruby -v code/hash/merge-vs-double-splat-operator.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#**other 203.060M i/100ms
Hash#merge 204.370M i/100ms
Calculating -------------------------------------
Hash#**other 2.031B (± 1.4%) i/s - 10.153B in 5.000277s
Hash#merge 2.029B (± 1.4%) i/s - 10.218B in 5.036241s
Comparison:
Hash#**other: 2030873116.0 i/s
Hash#merge: 2029363330.6 i/s - same-ish: difference falls within error
$ ruby -v code/hash/merge-vs-merge-bang.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#merge 276.000 i/100ms
Hash#merge! 21.850k i/100ms
Calculating -------------------------------------
Hash#merge 3.224k (± 4.8%) i/s - 16.284k in 5.064074s
Hash#merge! 221.406k (± 4.0%) i/s - 1.114M in 5.041762s
Comparison:
Hash#merge!: 221406.1 i/s
Hash#merge: 3223.6 i/s - 68.68x (± 0.00) slower
$ ruby -v code/hash/slice-native-vs-before-native.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#native-slice 938.041k i/100ms
Array#each 873.691k i/100ms
Array#each_w/_object 879.417k i/100ms
Hash#select-include 1.227M i/100ms
Calculating -------------------------------------
Hash#native-slice 10.315M (± 4.2%) i/s - 51.592M in 5.011435s
Array#each 8.495M (± 3.7%) i/s - 42.811M in 5.047437s
Array#each_w/_object 9.017M (± 3.8%) i/s - 45.730M in 5.079120s
Hash#select-include 12.413M (± 4.1%) i/s - 62.562M in 5.049143s
Comparison:
Hash#select-include : 12413114.6 i/s
Hash#native-slice : 10315022.4 i/s - 1.20x (± 0.00) slower
Array#each_w/_object: 9017368.4 i/s - 1.38x (± 0.00) slower
Array#each : 8494583.3 i/s - 1.46x (± 0.00) slower
$ ruby -v code/hash/values-include-vs-value.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Hash#values.include? 183.000 i/100ms
Hash#value? 5.049k i/100ms
Calculating -------------------------------------
Hash#values.include? 2.159k (±11.6%) i/s - 10.614k in 5.027821s
Hash#value? 47.173k (± 1.2%) i/s - 237.303k in 5.031166s
Comparison:
Hash#value?: 47173.1 i/s
Hash#values.include?: 2158.6 i/s - 21.85x (± 0.00) slower
$ ruby -v code/method/call-vs-send-vs-method_missing.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
call 198.918M i/100ms
send 201.604M i/100ms
method_missing 201.179M i/100ms
Calculating -------------------------------------
call 2.054B (± 1.8%) i/s - 10.344B in 5.037874s
send 2.060B (± 1.8%) i/s - 10.483B in 5.090121s
method_missing 2.038B (± 2.0%) i/s - 10.260B in 5.035915s
Comparison:
send: 2060198161.8 i/s
call: 2053876156.2 i/s - same-ish: difference falls within error
method_missing: 2038242150.3 i/s - same-ish: difference falls within error
$ ruby -v code/proc-and-block/block-vs-to_proc.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Block 13.408k i/100ms
Symbol#to_proc 14.748k i/100ms
Calculating -------------------------------------
Block 148.930k (± 4.3%) i/s - 750.848k in 5.051892s
Symbol#to_proc 149.546k (± 4.0%) i/s - 752.148k in 5.037995s
Comparison:
Symbol#to_proc: 149545.9 i/s
Block: 148929.6 i/s - same-ish: difference falls within error
$ ruby -v code/proc-and-block/proc-call-vs-yield.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
block.call 202.888M i/100ms
block + yield 208.038M i/100ms
unused block 204.389M i/100ms
yield 203.232M i/100ms
Calculating -------------------------------------
block.call 2.063B (± 2.1%) i/s - 10.347B in 5.018644s
block + yield 2.059B (± 1.9%) i/s - 10.402B in 5.052785s
unused block 2.071B (± 1.9%) i/s - 10.424B in 5.036139s
yield 2.066B (± 1.7%) i/s - 10.365B in 5.019532s
Comparison:
unused block: 2070559037.1 i/s
yield: 2065519777.9 i/s - same-ish: difference falls within error
block.call: 2062654496.6 i/s - same-ish: difference falls within error
block + yield: 2059385352.6 i/s - same-ish: difference falls within error
$ ruby -v code/range/cover-vs-include.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
range#cover? 13.191k i/100ms
range#include? 176.000 i/100ms
range#member? 386.000 i/100ms
plain compare 11.041k i/100ms
Calculating -------------------------------------
range#cover? 73.157k (±32.1%) i/s - 316.584k in 5.023149s
range#include? 4.754k (±33.0%) i/s - 20.768k in 5.026650s
range#member? 4.059k (±20.2%) i/s - 19.686k in 5.076912s
plain compare 140.203k (±27.9%) i/s - 618.296k in 5.011034s
Comparison:
plain compare: 140202.6 i/s
range#cover?: 73156.8 i/s - 1.92x (± 0.00) slower
range#include?: 4754.0 i/s - 29.49x (± 0.00) slower
range#member?: 4059.1 i/s - 34.54x (± 0.00) slower
$ ruby -v code/string/===-vs-=~-vs-match.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#match? 10.881M i/100ms
String#=~ 9.245M i/100ms
Regexp#=== 9.292M i/100ms
String#match 6.147M i/100ms
Calculating -------------------------------------
String#match? 110.250M (± 1.0%) i/s - 554.936M in 5.033964s
String#=~ 95.044M (± 1.7%) i/s - 480.717M in 5.059349s
Regexp#=== 95.521M (± 2.0%) i/s - 483.185M in 5.060458s
String#match 62.408M (± 1.7%) i/s - 313.472M in 5.024406s
Comparison:
String#match?: 110250074.6 i/s
Regexp#===: 95520832.2 i/s - 1.15x (± 0.00) slower
String#=~: 95044412.4 i/s - 1.16x (± 0.00) slower
String#match: 62407745.3 i/s - 1.77x (± 0.00) slower
$ ruby -v code/string/casecmp-vs-downcase-==.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#downcase + == 1.370M i/100ms
String#casecmp 2.397M i/100ms
Calculating -------------------------------------
String#downcase + == 14.883M (± 4.8%) i/s - 75.365M in 5.076119s
String#casecmp 24.780M (± 4.1%) i/s - 124.657M in 5.039585s
Comparison:
String#casecmp: 24779942.8 i/s
String#downcase + ==: 14883325.8 i/s - 1.66x (± 0.00) slower
$ ruby -v code/string/concatenation.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#+ 4.745M i/100ms
String#concat 6.687M i/100ms
String#append 6.520M i/100ms
"foo" "bar" 201.636M i/100ms
"#{'foo'}#{'bar'}" 203.830M i/100ms
Calculating -------------------------------------
String#+ 66.103M (± 5.1%) i/s - 332.183M in 5.039749s
String#concat 66.829M (± 4.7%) i/s - 334.336M in 5.014373s
String#append 65.565M (± 3.7%) i/s - 332.534M in 5.079414s
"foo" "bar" 2.019B (± 1.0%) i/s - 10.283B in 5.093708s
"#{'foo'}#{'bar'}" 2.020B (± 0.8%) i/s - 10.192B in 5.044603s
Comparison:
"#{'foo'}#{'bar'}": 2020423237.8 i/s
"foo" "bar": 2019039313.2 i/s - same-ish: difference falls within error
String#concat: 66828546.4 i/s - 30.23x (± 0.00) slower
String#+: 66102909.1 i/s - 30.56x (± 0.00) slower
String#append: 65564675.9 i/s - 30.82x (± 0.00) slower
$ ruby -v code/string/dup-vs-unary-plus.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#+@ 200.304M i/100ms
String#dup 202.275M i/100ms
Calculating -------------------------------------
String#+@ 2.012B (± 1.5%) i/s - 10.215B in 5.077691s
String#dup 2.019B (± 1.3%) i/s - 10.114B in 5.009337s
Comparison:
String#dup: 2019347735.0 i/s
String#+@: 2012309682.9 i/s - same-ish: difference falls within error
$ ruby -v code/string/end-string-checking-match-vs-end_with.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#=~ 903.610k i/100ms
String#match? 951.582k i/100ms
String#end_with? 6.857M i/100ms
Calculating -------------------------------------
String#=~ 9.247M (± 2.9%) i/s - 46.988M in 5.086241s
String#match? 12.853M (± 0.7%) i/s - 64.708M in 5.034632s
String#end_with? 67.885M (± 0.7%) i/s - 342.826M in 5.050355s
Comparison:
String#end_with?: 67884893.9 i/s
String#match?: 12853047.5 i/s - 5.28x (± 0.00) slower
String#=~: 9246507.8 i/s - 7.34x (± 0.00) slower
$ ruby -v code/string/gsub-vs-sub.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#gsub 119.693k i/100ms
String#sub 264.442k i/100ms
String#dup["string"]=
8.878M i/100ms
Calculating -------------------------------------
String#gsub 3.393M (±10.3%) i/s - 16.757M in 5.012174s
String#sub 4.699M (± 9.8%) i/s - 23.271M in 5.012087s
String#dup["string"]=
88.505M (± 2.0%) i/s - 443.909M in 5.017543s
Comparison:
String#dup["string"]=: 88504958.3 i/s
String#sub: 4698823.8 i/s - 18.84x (± 0.00) slower
String#gsub: 3392656.5 i/s - 26.09x (± 0.00) slower
$ ruby -v code/string/gsub-vs-tr.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#gsub 58.771k i/100ms
String#tr 80.352k i/100ms
Calculating -------------------------------------
String#gsub 1.719M (± 8.6%) i/s - 8.522M in 5.005664s
String#tr 824.549k (± 4.2%) i/s - 4.178M in 5.077295s
Comparison:
String#gsub: 1718783.5 i/s
String#tr: 824549.2 i/s - 2.08x (± 0.00) slower
$ ruby -v code/string/mutable_vs_immutable_strings.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Without Freeze 199.298M i/100ms
With Freeze 200.017M i/100ms
Calculating -------------------------------------
Without Freeze 2.025B (± 1.1%) i/s - 10.164B in 5.020215s
With Freeze 2.039B (± 1.4%) i/s - 10.201B in 5.004729s
Comparison:
With Freeze: 2038649687.7 i/s
Without Freeze: 2024913609.7 i/s - same-ish: difference falls within error
$ ruby -v code/string/remove-extra-spaces-or-other-chars.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#gsub/regex+/ 4.160k i/100ms
String#squeeze 25.107k i/100ms
Calculating -------------------------------------
String#gsub/regex+/ 56.105k (± 5.6%) i/s - 282.880k in 5.059286s
String#squeeze 246.641k (± 3.6%) i/s - 1.255M in 5.097092s
Comparison:
String#squeeze: 246641.0 i/s
String#gsub/regex+/: 56105.1 i/s - 4.40x (± 0.00) slower
$ ruby -v code/string/start-string-checking-match-vs-start_with.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#=~ 1.936M i/100ms
String#match? 1.641M i/100ms
String#start_with? 13.120M i/100ms
Calculating -------------------------------------
String#=~ 20.176M (± 3.8%) i/s - 102.604M in 5.092913s
String#match? 33.050M (± 2.0%) i/s - 165.750M in 5.017014s
String#start_with? 128.424M (± 2.0%) i/s - 642.885M in 5.008006s
Comparison:
String#start_with?: 128424393.3 i/s
String#match?: 33050473.5 i/s - 3.89x (± 0.00) slower
String#=~: 20176302.0 i/s - 6.37x (± 0.00) slower
$ ruby -v code/string/start_with-vs-substring-==.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#start_with? 78.475k i/100ms
String#[0, n] == 139.264k i/100ms
String#[RANGE] == 142.171k i/100ms
String#[0...n] == 107.716k i/100ms
Calculating -------------------------------------
String#start_with? 3.624M (± 2.9%) i/s - 18.128M in 5.006999s
String#[0, n] == 1.441M (± 4.0%) i/s - 7.242M in 5.034027s
String#[RANGE] == 1.448M (± 4.1%) i/s - 7.251M in 5.018241s
String#[0...n] == 1.100M (± 3.3%) i/s - 5.494M in 5.000688s
Comparison:
String#start_with?: 3623502.8 i/s
String#[RANGE] ==: 1447596.1 i/s - 2.50x (± 0.00) slower
String#[0, n] ==: 1441184.1 i/s - 2.51x (± 0.00) slower
String#[0...n] ==: 1099881.7 i/s - 3.29x (± 0.00) slower
$ ruby -v code/string/sub!-vs-gsub!-vs-[]=.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#['string']= 8.700M i/100ms
String#sub!'string' 353.644k i/100ms
String#gsub!'string' 311.983k i/100ms
String#[/regexp/]= 1.047M i/100ms
String#sub!/regexp/ 914.565k i/100ms
String#gsub!/regexp/ 318.991k i/100ms
Calculating -------------------------------------
String#['string']= 86.786M (± 0.8%) i/s - 435.021M in 5.012925s
String#sub!'string' 4.633M (±13.9%) i/s - 21.572M in 5.031413s
String#gsub!'string' 3.582M (± 4.6%) i/s - 18.095M in 5.064048s
String#[/regexp/]= 10.569M (± 2.9%) i/s - 53.379M in 5.055132s
String#sub!/regexp/ 9.250M (± 2.1%) i/s - 46.643M in 5.044937s
String#gsub!/regexp/ 4.023M (± 5.9%) i/s - 20.096M in 5.014639s
Comparison:
String#['string']=: 86785881.0 i/s
String#[/regexp/]=: 10568701.2 i/s - 8.21x (± 0.00) slower
String#sub!/regexp/: 9250134.2 i/s - 9.38x (± 0.00) slower
String#sub!'string': 4633363.4 i/s - 18.73x (± 0.00) slower
String#gsub!/regexp/: 4023102.3 i/s - 21.57x (± 0.00) slower
String#gsub!'string': 3581781.1 i/s - 24.23x (± 0.00) slower
$ ruby -v code/string/sub-vs-chomp-vs-delete_suffix.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#sub 1.435M i/100ms
String#chomp 3.143M i/100ms
String#delete_suffix 4.039M i/100ms
Calculating -------------------------------------
String#sub 14.729M (± 3.6%) i/s - 74.614M in 5.073380s
String#chomp 31.272M (± 0.8%) i/s - 157.137M in 5.025170s
String#delete_suffix 41.348M (± 4.2%) i/s - 210.043M in 5.089133s
Comparison:
String#delete_suffix: 41348415.9 i/s
String#chomp: 31271854.3 i/s - 1.32x (± 0.00) slower
String#sub: 14728721.5 i/s - 2.81x (± 0.00) slower
$ ruby -v code/string/sub-vs-delete_prefix.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#delete_prefix 202.158M i/100ms
String#sub 9.387M i/100ms
Calculating -------------------------------------
String#delete_prefix 2.021B (± 1.1%) i/s - 10.108B in 5.003130s
String#sub 92.751M (± 0.7%) i/s - 469.354M in 5.060600s
Comparison:
String#delete_prefix: 2020553906.2 i/s
String#sub: 92751492.1 i/s - 21.78x (± 0.00) slower
$ ruby -v code/string/unpack1-vs-unpack[0].rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
String#unpack1 956.682k i/100ms
String#unpack[0] 1.034M i/100ms
Calculating -------------------------------------
String#unpack1 10.229M (± 4.4%) i/s - 51.661M in 5.060718s
String#unpack[0] 10.146M (± 4.1%) i/s - 50.663M in 5.002403s
Comparison:
String#unpack1: 10229066.1 i/s
String#unpack[0]: 10145700.0 i/s - same-ish: difference falls within error
$ ruby -v code/time/iso8601-vs-parse.rb
truffleruby 23.0.0-dev-33ae0fe4, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
Warming up --------------------------------------
Time.iso8601 13.164k i/100ms
Time.parse 177.000 i/100ms
Calculating -------------------------------------
Time.iso8601 228.122k (±12.0%) i/s - 1.132M in 5.028708s
Time.parse 4.984k (±24.3%) i/s - 21.771k in 5.012634s
Comparison:
Time.iso8601: 228121.9 i/s
Time.parse: 4983.9 i/s - 45.77x (± 0.00) slower