aboutsummaryrefslogtreecommitdiffstats
path: root/benchmark
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-06-09 16:10:30 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-06-09 20:22:30 +0900
commitab6eb3786c94e69c561080cbb796c2381702a3a4 (patch)
tree2fe551edd62566939a7760439851fd7ad90b2d13 /benchmark
parentd54f66d1b4ce32d78b526b1ea9e3f213a763d07c (diff)
downloadruby-ab6eb3786c94e69c561080cbb796c2381702a3a4.tar.gz
Optimize `Regexp#dup` and `Regexp.new(/RE/)`
When copying from another regexp, copy already built `regex_t` instead of re-compiling its source.
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/regexp_dup.yml6
-rw-r--r--benchmark/regexp_new.yml7
2 files changed, 13 insertions, 0 deletions
diff --git a/benchmark/regexp_dup.yml b/benchmark/regexp_dup.yml
new file mode 100644
index 0000000000..52f89991cd
--- /dev/null
+++ b/benchmark/regexp_dup.yml
@@ -0,0 +1,6 @@
+prelude: |
+ str = "a" * 1000
+ re = Regexp.new(str)
+
+benchmark:
+ dup: re.dup
diff --git a/benchmark/regexp_new.yml b/benchmark/regexp_new.yml
new file mode 100644
index 0000000000..bc9ab3ca21
--- /dev/null
+++ b/benchmark/regexp_new.yml
@@ -0,0 +1,7 @@
+prelude: |
+ str = "a" * 1000
+ re = Regexp.new(str)
+
+benchmark:
+ string: Regexp.new(str)
+ regexp: Regexp.new(re)