Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
_checkUsedExpressionAttributes
(version: 3)
Comparing performance of:
Original expr vs Eval prepared regex vs New JSON Wrapper vs New Array Wrapper
Created:
8 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var cbscope, property, attrscope, propnames, listenerkey, execexpr, cbafter, cbbefore, isDomExpr; var key = "[WebApp.ui.form.field.Field][getFieldValueInUserFormat]", classname = "WebApp.ui.form.field.Field", attrname = "_parseValue2InputCatched", preparedRegEx = new RegExp("\\[([^\\]]+)\\]\\[" + attrname + "\\]"), propnames = ["A", "B", "C", attrname]; var WebAppExpr = { _functsList: {}, _functsListNew: {}, _functsListArray: [] }; var attrscopeClass = function() {}; attrscopeClass.prototype.is = function(classname) { return true; } attrscopeClass.prototype.getClassNames = function(classname) { return ["WebApp.ui.form.field.Field"]; } var attrscope = new attrscopeClass(); var __addListenersForUsedExpressionChanged = function() {}; for (var c=0; c < 100; c++) { var c_class = "CLASS_" + c, functions = []; for (var i=0; i < 100; i++) { var c_fn = "FUNCTION_" + i; functions[i] = c_fn; WebAppExpr._functsList["[" + c_class + "][" + c_fn + "]"] = propnames; } WebAppExpr._functsListArray.push({ classname : c_class, functions : functions, propnames : propnames }); WebAppExpr._functsListNew[c_class] = { functions : functions, propnames : propnames } } WebAppExpr._functsListArray.push({ classname : classname, functions : ["getFieldValueInUserFormat"], propnames : propnames }); WebAppExpr._functsListNew[classname] = { functions : ["getFieldValueInUserFormat"], propnames : propnames } WebAppExpr._functsList[key] = propnames;
Tests:
Original expr
for (var key in WebAppExpr._functsList) { var matcher = new RegExp("\\[([^\\]]+)\\]\\[" + attrname + "\\]").exec(key); if (matcher != null) { var classname = matcher[1]; if (attrscope.is(classname)) { var propnames = WebAppExpr._functsList[key]; for (var ifnprop=0, nfnprops = propnames.length; ifnprop < nfnprops; ifnprop++) { __addListenersForUsedExpressionChanged(cbscope, property, attrscope, propnames[ifnprop], listenerkey, execexpr, cbafter, cbbefore, isDomExpr); } } } }
Eval prepared regex
for (var key in WebAppExpr._functsList) { var matcher = preparedRegEx.exec(key); if (matcher != null) { var classname = matcher[1]; if (attrscope.is(classname)) { var propnames = WebAppExpr._functsList[key]; for (var ifnprop=0, nfnprops = propnames.length; ifnprop < nfnprops; ifnprop++) { __addListenersForUsedExpressionChanged(cbscope, property, attrscope, propnames[ifnprop], listenerkey, execexpr, cbafter, cbbefore, isDomExpr); } } } }
New JSON Wrapper
attrscope.getClassNames().forEach(function(classname) { var functsList = WebAppExpr._functsListNew[classname], propsNames = functsList != null ? functsList[attrname] : null; if (propsNames != null) { for (var ifnprop=0, nfnprops = propsNames.length; ifnprop < nfnprops; ifnprop++) { __addListenersForUsedExpressionChanged(cbscope, property, attrscope, propsNames[ifnprop], listenerkey, execexpr, cbafter, cbbefore, isDomExpr); } } })
New Array Wrapper
attrscope.getClassNames().forEach(function(classname) { var functsList = WebAppExpr._functsListArray.find(function(listopt) { return listopt.classname === classname}), propsNames = functsList != null ? functsList[attrname] : null; if (propsNames != null) { for (var ifnprop=0, nfnprops = propsNames.length; ifnprop < nfnprops; ifnprop++) { __addListenersForUsedExpressionChanged(cbscope, property, attrscope, propsNames[ifnprop], listenerkey, execexpr, cbafter, cbbefore, isDomExpr); } } })
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Original expr
Eval prepared regex
New JSON Wrapper
New Array Wrapper
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):
I'll provide an answer based on the provided benchmark results. It appears that we have four test cases: `New JSON Wrapper`, `New Array Wrapper`, `Eval prepared regex`, and `Original expr`. The results show that: * The `New JSON Wrapper` and `New Array Wrapper` tests are very similar, with the former having a significantly higher number of executions per second (2880022.25 vs 1413649.75). * The `Eval prepared regex` test is slower than the other two (115.4171371459961 executions per second), but still relatively fast. * The `Original expr` test has a very low number of executions per second (4.9535603523254395), indicating that it may be skipped or optimized. Based on this information, I would suggest that: * The `New JSON Wrapper` and `New Array Wrapper` tests should be further optimized to improve their performance. * The `Eval prepared regex` test should remain as is, but with possible optimization opportunities. * The `Original expr` test should be skipped or optimized, possibly by removing or simplifying the code. However, without more context about the specific requirements and constraints of these benchmarks, it's difficult to provide a more definitive answer.
Related benchmarks:
Template literals + regex vs safe accessor
new RegExp mem test
testes
Bool check vs regex
Check first character
Comments
Confirm delete:
Do you really want to delete benchmark?