]> git.kaiwu.me - njs.git/commitdiff
Added benchmarks for String.prototype.split().
authorDmitry Volyntsev <xeioex@nginx.com>
Tue, 8 Jun 2021 18:01:25 +0000 (18:01 +0000)
committerDmitry Volyntsev <xeioex@nginx.com>
Tue, 8 Jun 2021 18:01:25 +0000 (18:01 +0000)
src/test/njs_benchmark.c

index bbe052d5362c0d552963334879e7ed0a1d04e86e..ff8f38077fb19cb544d098c33dd56d50bb9c49dc 100644 (file)
@@ -316,6 +316,21 @@ static njs_benchmark_test_t  njs_test[] =
       njs_str("undefined"),
       1 },
 
+    { "regexp split",
+      njs_str("'a a'.split(/ /).length"),
+      njs_str("2"),
+      100 },
+
+    { "regexp 10K split",
+      njs_str("'a '.repeat(10000).split(/ /).length"),
+      njs_str("10001"),
+      1 },
+
+    { "simple 100K split",
+      njs_str("'a '.repeat(100000).split(' ').length"),
+      njs_str("100001"),
+      1 },
+
     { "external property ($shared.uri)",
       njs_str("$shared.uri"),
       njs_str("shared"),