Issue #10329 has been updated by Eric Wong.

Related to Feature #10326: [PATCH] optimize: recv << "literal string" added

----------------------------------------
Feature #10329: [PATCH 2/1] optimize: foo == "literal string"
https://bugs.ruby-lang.org/issues/10329#change-49213

* Author: Eric Wong
* Status: Open
* Priority: Normal
* Assignee: 
* Category: core
* Target version: current: 2.2.0
----------------------------------------
Follow-up-to: [Feature #10326] (optimize: recv << "literal string")

This speeds up some string comparisons greatly, vm2_streq1 results:

[["loop_whileloop2",
  [[0.21688890410587192,
    0.21697380719706416,
    0.21685226494446397,
    0.21750432904809713],
   [0.21682232478633523,
    0.2153299949131906,
    0.21504606027156115,
    0.21595032326877117]]],
 ["vm2_streq1",
  [[0.8923470871523023,
    0.9007423971779644,
    0.8952413029037416,
    0.9235154730267823],
   [0.42798056406900287,
    0.3970582918263972,
    0.4244600120000541,
    0.4243976562283933]]]]

Elapsed time: 7.020550268 (sec)
-----------------------------------------------------------
benchmark results:
minimum results in each 4 measurements.
Execution time (sec)
name	a	b
loop_whileloop2	0.217	0.215
vm2_streq1*	0.675	0.182

Speedup ratio: compare with the result of `a' (greater is better)
name	b
loop_whileloop2	1.008
vm2_streq1*	3.711

I have not figured out the reverse (yoda condition), yet:

	"literal string" == foo
---
 benchmark/bm_vm2_streq1.rb |  6 ++++++
 compile.c                  | 23 +++++++++++++++++++++++
 insns.def                  | 21 +++++++++++++++++++++
 test/ruby/test_string.rb   | 29 +++++++++++++++++++++++++++++
 4 files changed, 79 insertions(+)
 create mode 100644 benchmark/bm_vm2_streq1.rb


---Files--------------------------------
0002-optimize-foo-literal-string.patch (4.36 KB)


-- 
https://bugs.ruby-lang.org/