Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Randlskdjf
(version: 0)
Comparing performance of:
String.split vs Regex.match
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
string = `{"m":"symbol_resolved","p":["cs_QKsRvaqOGKbx","sds_sym_1",{"session_holidays":"20000117,20000221,20000421,20000529,20000704,20000904,20001123,20001225,20010101,20010115,20010219,20010413,20010528,20010704,20010903,20011122,20011225,20020101,20020121,20020218,20020329,20020527,20020704,20020902,20021128,20021225,20030101,20030120,20030217,20030418,20030526,20030704,20030901,20031127,20031225,20040101,20040119,20040216,20040409,20040531,20040611,20040705,20040906,20041125,20041224,20050117,20050221,20050325,20050530,20050704,20050905,20051124,20051226,20060102,20060116,20060220,20060414,20060529,20060704,20060904,20061123,20061225,20070101,20070102,20070115,20070219,20070406,20070528,20070704,20070903,20071122,20071225,20080101,20080121,20080218,20080321,20080526,20080704,20080901,20081127,20081225,20090101,20090119,20090216,20090410,20090525,20090703,20090907,20091126,20091225,20100101,20100118,20100215,20100402,20100531,20100705,20100906,20101125,20101224,20110117,20110221,20110422,20110530,20110704,20110905,20111124,20111226,20120102,20120116,20120220,20120406,20120528,20120704,20120903,20121122,20121225,20130101,20130121,20130218,20130329,20130527,20130704,20130902,20131128,20131225,20140101,20140120,20140217,20140418,20140526,20140704,20140901,20141127,20141225,20150101,20150119,20150216,20150403,20150525,20150703,20150907,20151126,20151225,20160101,20160118,20160215,20160325,20160530,20160704,20160905,20161124,20161226,20170102,20170116,20170220,20170414,20170529,20170704,20170904,20171123,20171225,20180101,20180115,20180219,20180330,20180528,20180704,20180903,20181122,20181225,20190101,20190121,20190218,20190419,20190527,20190704,20190902,20191128,20191225,20200101,20200120,20200217,20200410,20200525,20200703,20200907,20201126,20201225,20210101,20210118,20210215,20210402,20210531,20210705,20210906,20211125,20211224,20220117,20220221,20220415,20220530,20220620,20220704,20220905,20221124,20221226,20230102,20230116,20230220,20230407,20230529,20230619,20230704,20230904,20231123,20231225","subsession_id":"regular","provider_id":"ice","currency_id":"USD","country":"US","pro_perm":"nasdaq","allowed_adjustment":"any","short_description":"Tesla, Inc.","variable_tick_size":"0.0001 1 0.01","sedol":"B616C79","nsin":"88160R101","isin":"US88160R1014","local_code":"TSLA","language":"en","local_description":"Tesla, Inc.","name":"TSLA","full_name":"BATS:TSLA","pro_name":"NASDAQ:TSLA","base_name":["NASDAQ:TSLA"],"description":"Tesla, Inc.","exchange":"Cboe BZX","pricescale":100,"pointvalue":1.0,"minmov":1,"session":"0930-1600","session_display":"0930-1600","subsessions":[{"description":"Regular Trading Hours","id":"regular","private":false,"session":"0930-1600","session-display":"0930-1600"},{"description":"Extended Trading Hours","id":"extended","private":false,"session":"0400-2000","session-display":"0400-2000"},{"description":"Premarket","id":"premarket","private":true,"session":"0400-0930","session-display":"0400-0930"},{"description":"Postmarket","id":"postmarket","private":true,"session":"1600-2000","session-display":"1600-2000"}],"type":"stock","typespecs":["common"],"resolutions":[],"has_intraday":true,"fractional":false,"listed_exchange":"NASDAQ","legs":["BATS:TSLA"],"is_tradable":true,"minmove2":0,"timezone":"America/New_York","aliases":["BATS_MIX:TSLA"],"alternatives":["BATS_DLY:TSLA"],"currency_code":"USD","is_replayable":true,"has_adjustment":true,"has_extended_hours":true,"bar_source":"trade","bar_transform":"none","bar_fillgaps":false,"visible_plots_set":"ohlcv"}],"t":1644345402,"t_ms":1644345402214}`; regex = /"p":\["([^"]+)"/;
Tests:
String.split
let data = JSON.parse(string); console.log(data.p[0]);
Regex.match
let match = string.match(regex); if (match) { console.log(match[1]); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
String.split
Regex.match
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided JSON and explain what is being tested. **Benchmark Definition** The `Benchmark Definition` json provides metadata about the benchmark, including its name, description, and script preparation code. In this case: * The script preparation code defines two test cases: one that uses a regular expression (`Regex.match`) to extract the first group from the `string` variable (containing the JSON representation of a stock symbol), and another that simply splits the `string` into an array using the `split` method. * Both tests use a fixed input string, which appears to be a JSON representation of a stock symbol. **Individual Test Cases** The two individual test cases are: 1. **String.split**: This test case measures the performance of the `split` method on the input string. It's likely that this is a baseline or reference test. 2. **Regex.match**: This test case measures the performance of the regular expression (`regex`) used to extract the first group from the input string. **Test Results** The latest benchmark result shows two tests with their respective results: * **Regex.match**: The test executed approximately 41076 times per second on a Chrome 98 browser on a Linux desktop, running at an execution rate of 97836.828125 seconds. * **String.split**: The test executed approximately 97836 times per second on a Chrome 98 browser on a Linux desktop, running at an execution rate of 41076.72265625 seconds. **Interpretation** These results suggest that the regular expression (`Regex.match`) is slower than the `split` method for this specific use case. This could be due to various factors such as the complexity of the regular expression or differences in browser implementation. Keep in mind that these results are specific to this benchmark and may not generalize across all scenarios.
Related benchmarks:
parse hex to bytes
xorcipher
Consider signing in before you create benchmark.
String search vs Array search vs Obj key search
Comments
Confirm delete:
Do you really want to delete benchmark?