[njs] Added benchmarks for String.prototype.split().

Dmitry Volyntsev xeioex at nginx.com
Wed Jun 9 17:54:13 UTC 2021


details:   https://hg.nginx.org/njs/rev/5516f717a8c9
branches:  
changeset: 1655:5516f717a8c9
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Tue Jun 08 18:01:25 2021 +0000
description:
Added benchmarks for String.prototype.split().

diffstat:

 src/test/njs_benchmark.c |  15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diffs (25 lines):

diff -r 913a69870b49 -r 5516f717a8c9 src/test/njs_benchmark.c
--- a/src/test/njs_benchmark.c	Sat Jun 05 11:55:08 2021 +0000
+++ b/src/test/njs_benchmark.c	Tue Jun 08 18:01:25 2021 +0000
@@ -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"),


More information about the nginx-devel mailing list