Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
RegEx.test vs. String.includes vs. String.match vs PreparedRegEx.test
(version: 0)
Comparing performance of:
RegEx.test vs String.includes vs String.match vs PreparedRegEx.test
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var string = `<div class="o_group row align-items-start"><div class="o_inner_group grid col-lg-6"><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell o_wrap_label flex-grow-1 flex-sm-grow-0 w-100 text-break text-900"><label class="o_form_label" for="partner_id_1">Customer<sup class="text-info p-1" data-tooltip-template="web.FieldTooltip" data-tooltip-info="{"field":{"help":"Linked partner (optional). Usually created when converting the lead. You can find a partner by its Name, TIN, Email or Internal Reference."}}" data-tooltip-touch-tap-to-show="true">?</sup></label></div><div class="o_cell o_wrap_input flex-grow-1 flex-sm-grow-0 text-break" style="width: 100%;"><div name="partner_id" class="o_field_widget o_field_res_partner_many2one"><div class="o_field_many2one_selection"><div class="o_input_dropdown"><div class="o-autocomplete dropdown"><input type="text" class="o-autocomplete--input o_input" autocomplete="off" role="combobox" aria-autocomplete="list" aria-haspopup="listbox" id="partner_id_1" placeholder="" aria-expanded="false"></div><span class="o_dropdown_button"></span></div></div><div class="o_field_many2one_extra"></div></div></div></div><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell flex-grow-1 flex-sm-grow-0 o_wrap_label w-100 text-break text-900" style=""><label class="o_form_label oe_inline" for="email_from_0">Email</label></div><div class="o_cell flex-grow-1 flex-sm-grow-0" style="width: 100%;"><div class="o_row o_row_readonly"><div name="email_from" class="o_field_widget o_field_email"><div class="d-inline-flex w-100"><input class="o_input" type="email" autocomplete="off" id="email_from_0"></div></div></div></div></div><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell flex-grow-1 flex-sm-grow-0 o_wrap_label w-100 text-break text-900" style=""><label class="o_form_label oe_inline" for="phone_0">Phone</label></div><div class="o_cell flex-grow-1 flex-sm-grow-0" style="width: 100%;"><div class="o_row o_row_readonly"><div name="phone" class="o_field_widget o_field_phone"><div class="o_phone_content d-inline-flex w-100"><input class="o_input" type="tel" autocomplete="off" id="phone_0"><a class="o_phone_form_link ms-3 d-inline-flex align-items-center" href="tel:0674552302"><i class="fa fa-phone"></i><small class="fw-bold ms-1">Call</small></a><a class="ms-3 d-inline-flex align-items-center o_field_phone_sms" title="Send SMS Text Message" href="sms:0674552302"><i class="fa fa-mobile"></i><small class="fw-bold ms-1">SMS</small></a></div></div></div></div></div></div><div class="o_inner_group grid col-lg-6"><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell o_wrap_label flex-grow-1 flex-sm-grow-0 w-100 text-break text-900"><label class="o_form_label" for="user_id_0">Salesperson</label></div><div class="o_cell o_wrap_input flex-grow-1 flex-sm-grow-0 text-break" style="width: 100%;"><div name="user_id" class="o_field_widget o_field_many2one_avatar_user o_field_many2one_avatar"><div class="d-flex align-items-center gap-1" data-tooltip="Camille Ringover"><span class="o_avatar o_m2o_avatar"><img class="rounded" src="/web/image/res.users/2/avatar_128"></span><div class="o_field_many2one_selection"><div class="o_input_dropdown"><div class="o-autocomplete dropdown"><input type="text" class="o-autocomplete--input o_input" autocomplete="off" role="combobox" aria-autocomplete="list" aria-haspopup="listbox" id="user_id_0" placeholder="" href="callto:0674552302" aria-expanded="false"></div><span class="o_dropdown_button"></span></div><button type="button" class="btn btn-link text-action oi o_external_button oi-arrow-right" tabindex="-1" draggable="false" aria-label="Internal link" data-tooltip="Internal link"></button></div><div class="o_field_many2one_extra"></div></div></div></div></div><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell flex-grow-1 flex-sm-grow-0 o_wrap_label w-100 text-break text-900" style=""><label class="o_form_label" for="date_deadline_0">Expected Closing<sup class="text-info p-1" data-tooltip-template="web.FieldTooltip" data-tooltip-info="{"field":{"help":"Estimate of the date on which the opportunity will be won."}}" data-tooltip-touch-tap-to-show="true">?</sup></label></div><div class="o_cell flex-grow-1 flex-sm-grow-0" style="width: 100%;"><div class="o_lead_opportunity_form_inline_fields"><div name="date_deadline" class="o_field_widget o_field_date oe_inline"><div class="d-flex gap-2 align-items-center"><input type="text" class="o_input cursor-pointer" autocomplete="off" id="date_deadline_0" data-field="date_deadline"></div></div><div name="priority" class="o_field_widget o_field_priority oe_inline align-top"><div class="o_priority" role="radiogroup" name="priority" aria-label="Priority"><a href="#" class="o_priority_star fa fa-star-o" role="radio" tabindex="-1" data-tooltip="Priority: Medium" aria-lab<div class="o_group row align-items-start"><div class="o_inner_group grid col-lg-6"><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell o_wrap_label flex-grow-1 flex-sm-grow-0 w-100 text-break text-900"><label class="o_form_label" for="partner_id_1">Customer<sup class="text-info p-1" data-tooltip-template="web.FieldTooltip" data-tooltip-info="{"field":{"help":"Linked partner (optional). Usually created when converting the lead. You can find a partner by its Name, TIN, Email or Internal Reference."}}" data-tooltip-touch-tap-to-show="true">?</sup></label></div><div class="o_cell o_wrap_input flex-grow-1 flex-sm-grow-0 text-break" style="width: 100%;"><div name="partner_id" class="o_field_widget o_field_res_partner_many2one"><div class="o_field_many2one_selection"><div class="o_input_dropdown"><div class="o-autocomplete dropdown"><input type="text" class="o-autocomplete--input o_input" autocomplete="off" role="combobox" aria-autocomplete="list" aria-haspopup="listbox" id="partner_id_1" placeholder="" aria-expanded="false"></div><span class="o_dropdown_button"></span></div></div><div class="o_field_many2one_extra"></div></div></div></div><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell flex-grow-1 flex-sm-grow-0 o_wrap_label w-100 text-break text-900" style=""><label class="o_form_label oe_inline" for="email_from_0">Email</label></div><div class="o_cell flex-grow-1 flex-sm-grow-0" style="width: 100%;"><div class="o_row o_row_readonly"><div name="email_from" class="o_field_widget o_field_email"><div class="d-inline-flex w-100"><input class="o_input" type="email" autocomplete="off" id="email_from_0"></div></div></div></div></div><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell flex-grow-1 flex-sm-grow-0 o_wrap_label w-100 text-break text-900" style=""><label class="o_form_label oe_inline" for="phone_0">Phone</label></div><div class="o_cell flex-grow-1 flex-sm-grow-0" style="width: 100%;"><div class="o_row o_row_readonly"><div name="phone" class="o_field_widget o_field_phone"><div class="o_phone_content d-inline-flex w-100"><input class="o_input" type="tel" autocomplete="off" id="phone_0"><a class="o_phone_form_link ms-3 d-inline-flex align-items-center" href="tel:0674552302"><i class="fa fa-phone"></i><small class="fw-bold ms-1">Call</small></a><a class="ms-3 d-inline-flex align-items-center o_field_phone_sms" title="Send SMS Text Message" href="sms:0674552302"><i class="fa fa-mobile"></i><small class="fw-bold ms-1">SMS</small></a></div></div></div></div></div></div><div class="o_inner_group grid col-lg-6"><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell o_wrap_label flex-grow-1 flex-sm-grow-0 w-100 text-break text-900"><label class="o_form_label" for="user_id_0">Salesperson</label></div><div class="o_cell o_wrap_input flex-grow-1 flex-sm-grow-0 text-break" style="width: 100%;"><div name="user_id" class="o_field_widget o_field_many2one_avatar_user o_field_many2one_avatar"><div class="d-flex align-items-center gap-1" data-tooltip="Camille Ringover"><span class="o_avatar o_m2o_avatar"><img class="rounded" src="/web/image/res.users/2/avatar_128"></span><div class="o_field_many2one_selection"><div class="o_input_dropdown"><div class="o-autocomplete dropdown"><input type="text" class="o-autocomplete--input o_input" autocomplete="off" role="combobox" aria-autocomplete="list" aria-haspopup="listbox" id="user_id_0" placeholder="" href="callto:0674552302" aria-expanded="false"></div><span class="o_dropdown_button"></span></div><button type="button" class="btn btn-link text-action oi o_external_button oi-arrow-right" tabindex="-1" draggable="false" aria-label="Internal link" data-tooltip="Internal link"></button></div><div class="o_field_many2one_extra"></div></div></div></div></div><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell flex-grow-1 flex-sm-grow-0 o_wrap_label w-100 text-break text-900" style=""><label class="o_form_label" for="date_deadline_0">Expected Closing<sup class="text-info p-1" data-tooltip-template="web.FieldTooltip" data-tooltip-info="{"field":{"help":"Estimate of the date on which the opportunity will be won."}}" data-tooltip-touch-tap-to-show="true">?</sup></label></div><div class="o_cell flex-grow-1 flex-sm-grow-0" style="width: 100%;"><div class="o_lead_opportunity_form_inline_fields"><div name="date_deadline" class="o_field_widget o_field_date oe_inline"><div class="d-flex gap-2 align-items-center"><input type="text" class="o_input cursor-pointer" autocomplete="off" id="date_deadline_0" data-field="date_deadline"></div></div><div name="priority" class="o_field_widget o_field_priority oe_inline align-top"><div class="o_priority" role="radiogroup" name="priority" aria-label="Priority"><a href="#" class="o_priority_star fa fa-star-o" role="radio" tabindex="-1" data-tooltip="Priority: Medium" aria-label="Medium"></a><a href="#" class="o_priority_star fa fa-star-o" role="radio" tabindex="-1" data-tooltip="Priority: High" aria-label="High"></a><a href="#" class="o_priority_star fa fa-star-o" role="radio" tabindex="-1" data-tooltip="Priority: Very High" aria-label="Very High"></a></div></div></div></div></div><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell o_wrap_label flex-grow-1 flex-sm-grow-0 w-100 text-break text-900"><label class="o_form_label" for="tag_ids_0">Tags<sup class="text-info p-1" data-tooltip-template="web.FieldTooltip" data-tooltip-info="{"field":{"help":"Classify and analyze your lead/opportunity categories like: Training, Service"}}" data-tooltip-touch-tap-to-show="true">?</sup></label></div><div class="o_cell o_wrap_input flex-grow-1 flex-sm-grow-0 text-break" style="width: 100%;"><div name="tag_ids" class="o_field_widget o_field_many2many_tags"><div class="o_field_tags d-inline-flex flex-wrap gap-1 o_tags_input o_input"><div class="o_field_many2many_selection d-inline-flex w-100"><div class="o_input_dropdown"><div class="o-autocomplete dropdown"><input type="text" class="o-autocomplete--input o_input" autocomplete="off" role="combobox" aria-autocomplete="list" aria-haspopup="listbox" id="tag_ids_0" placeholder="" aria-expanded="false"></dHello Worldiv><span class="o_dropdown_button"></span></div></div></div></div></div></div></div></div>el="Medium"></a><a href="#" class="o_priority_star fa fa-star-o" role="radio" tabindex="-1" data-tooltip="Priority: High" aria-label="High"></a><a href="#" class="o_priority_star fa fa-star-o" role="radio" tabindex="-1" data-tooltip="Priority: Very High" aria-label="Very High"></a></div></div></div></div></div><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell o_wrap_label flex-grow-1 flex-sm-grow-0 w-100 text-break text-900"><label class="o_form_label" for="tag_ids_0">Tags<sup class="text-info p-1" data-tooltip-template="web.FieldTooltip" data-tooltip-info="{"field":{"help":"Classify and analyze your lead/opportunity categories like: Training, Service"}}" data-tooltip-touch-tap-to-show="true">?</sup></label></div><div class="o_cell o_wrap_input flex-grow-1 flex-sm-grow-0 text-break" style="width: 100%;"><div name="tag_ids" class="o_field_widget o_field_many2many_tags"><div class="o_field_tags d-inline-flex flex-wrap gap-1 o_tags_input o_input"><div class="o_field_many2many_selection d-inline-flex w-100"><div class="o_input_dropdown"><div class="o-autocomplete dropdown"><input type="text" class="o-autocomplete--input o_input" autocomplete="off" role="combobox" aria-autocomplete="list" aria-haspopup="listbox" id="tag_ids_0" placeholder="" aria-expanded="false"></dHello Worldiv><span class="o_dropdown_button"></span></div></div></div></div></div></div></div></div><div class="o_group row align-items-start"><div class="o_inner_group grid col-lg-6"><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell o_wrap_label flex-grow-1 flex-sm-grow-0 w-100 text-break text-900"><label class="o_form_label" for="partner_id_1">Customer<sup class="text-info p-1" data-tooltip-template="web.FieldTooltip" data-tooltip-info="{"field":{"help":"Linked partner (optional). Usually created when converting the lead. You can find a partner by its Name, TIN, Email or Internal Reference."}}" data-tooltip-touch-tap-to-show="true">?</sup></label></div><div class="o_cell o_wrap_input flex-grow-1 flex-sm-grow-0 text-break" style="width: 100%;"><div name="partner_id" class="o_field_widget o_field_res_partner_many2one"><div class="o_field_many2one_selection"><div class="o_input_dropdown"><div class="o-autocomplete dropdown"><input type="text" class="o-autocomplete--input o_input" autocomplete="off" role="combobox" aria-autocomplete="list" aria-haspopup="listbox" id="partner_id_1" placeholder="" aria-expanded="false"></div><span class="o_dropdown_button"></span></div></div><div class="o_field_many2one_extra"></div></div></div></div><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell flex-grow-1 flex-sm-grow-0 o_wrap_label w-100 text-break text-900" style=""><label class="o_form_label oe_inline" for="email_from_0">Email</label></div><div class="o_cell flex-grow-1 flex-sm-grow-0" style="width: 100%;"><div class="o_row o_row_readonly"><div name="email_from" class="o_field_widget o_field_email"><div class="d-inline-flex w-100"><input class="o_input" type="email" autocomplete="off" id="email_from_0"></div></div></div></div></div><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell flex-grow-1 flex-sm-grow-0 o_wrap_label w-100 text-break text-900" style=""><label class="o_form_label oe_inline" for="phone_0">Phone</label></div><div class="o_cell flex-grow-1 flex-sm-grow-0" style="width: 100%;"><div class="o_row o_row_readonly"><div name="phone" class="o_field_widget o_field_phone"><div class="o_phone_content d-inline-flex w-100"><input class="o_input" type="tel" autocomplete="off" id="phone_0"><a class="o_phone_form_link ms-3 d-inline-flex align-items-center" href="tel:0674552302"><i class="fa fa-phone"></i><small class="fw-bold ms-1">Call</small></a><a class="ms-3 d-inline-flex align-items-center o_field_phone_sms" title="Send SMS Text Message" href="sms:0674552302"><i class="fa fa-mobile"></i><small class="fw-bold ms-1">SMS</small></a></div></div></div></div></div></div><div class="o_inner_group grid col-lg-6"><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell o_wrap_label flex-grow-1 flex-sm-grow-0 w-100 text-break text-900"><label class="o_form_label" for="user_id_0">Salesperson</label></div><div class="o_cell o_wrap_input flex-grow-1 flex-sm-grow-0 text-break" style="width: 100%;"><div name="user_id" class="o_field_widget o_field_many2one_avatar_user o_field_many2one_avatar"><div class="d-flex align-items-center gap-1" data-tooltip="Camille Ringover"><span class="o_avatar o_m2o_avatar"><img class="rounded" src="/web/image/res.users/2/avatar_128"></span><div class="o_field_many2one_selection"><div class="o_input_dropdown"><div class="o-autocomplete dropdown"><input type="text" class="o-autocomplete--input o_input" autocomplete="off" role="combobox" aria-autocomplete="list" aria-haspopup="listbox" id="user_id_0" placeholder="" href="callto:0674552302" aria-expanded="false"></div><span class="o_dropdown_button"></span></div><button type="button" class="btn btn-link text-action oi o_external_button oi-arrow-right" tabindex="-1" draggable="false" aria-label="Internal link" data-tooltip="Internal link"></button></div><div class="o_field_many2one_extra"></div></div></div></div></div><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell flex-grow-1 flex-sm-grow-0 o_wrap_label w-100 text-break text-900" style=""><label class="o_form_label" for="date_deadline_0">Expected Closing<sup class="text-info p-1" data-tooltip-template="web.FieldTooltip" data-tooltip-info="{"field":{"help":"Estimate of the date on which the opportunity will be won."}}" data-tooltip-touch-tap-to-show="true">?</sup></label></div><div class="o_cell flex-grow-1 flex-sm-grow-0" style="width: 100%;"><div class="o_lead_opportunity_form_inline_fields"><div name="date_deadline" class="o_field_widget o_field_date oe_inline"><div class="d-flex gap-2 align-items-center"><input type="text" class="o_input cursor-pointer" autocomplete="off" id="date_deadline_0" data-field="date_deadline"></div></div><div name="priority" class="o_field_widget o_field_priority oe_inline align-top"><div class="o_priority" role="radiogroup" name="priority" aria-label="Priority"><a href="#" class="o_priority_star fa fa-star-o" role="radio" tabindex="-1" data-tooltip="Priority: Medium" aria-label="Medium"></a><a href="#" class="o_priority_star fa fa-star-o" role="radio" tabindex="-1" data-tooltip="Priority: High" aria-label="High"></a><a href="#" class="o_priority_star fa fa-star-o" role="radio" tabindex="-1" data-tooltip="Priority: Very High" aria-label="Very High"></a></div></div></div></div></div><div class="o_wrap_field d-flex d-sm-contents flex-column mb-3 mb-sm-0"><div class="o_cell o_wrap_label flex-grow-1 flex-sm-grow-0 w-100 text-break text-900"><label class="o_form_label" for="tag_ids_0">Tags<sup class="text-info p-1" data-tooltip-template="web.FieldTooltip" data-tooltip-info="{"field":{"help":"Classify and analyze your lead/opportunity categories like: Training, Service"}}" data-tooltip-touch-tap-to-show="true">?</sup></label></div><div class="o_cell o_wrap_input flex-grow-1 flex-sm-grow-0 text-break" style="width: 100%;"><div name="tag_ids" class="o_field_widget o_field_many2many_tags"><div class="o_field_tags d-inline-flex flex-wrap gap-1 o_tags_input o_input"><div class="o_field_many2many_selection d-inline-flex w-100"><div class="o_input_dropdown"><div class="o-autocomplete dropdown"><input type="text" class="o-autocomplete--input o_input" autocomplete="off" role="combobox" aria-autocomplete="list" aria-haspopup="listbox" id="tag_ids_0" placeholder="" aria-expanded="false"></dHello Worldiv><span class="o_dropdown_button"></span></div></div></div></div></div></div></div></div>`; var regex = /Hello/; var prepared_regex = new RegExp('Hello');
Tests:
RegEx.test
regex.test(string);
String.includes
string.includes("Hello");
String.match
string.match("Hello");
PreparedRegEx.test
prepared_regex.test(string);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
RegEx.test
String.includes
String.match
PreparedRegEx.test
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Browser/OS:
Chrome 128 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
RegEx.test
2066963.8 Ops/sec
String.includes
16600077.0 Ops/sec
String.match
1579329.4 Ops/sec
PreparedRegEx.test
1920232.8 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I can help you analyze the code snippets and benchmark results. **Code Analysis** The code snippet appears to be HTML with some JavaScript code embedded within it. The HTML structure seems to be that of a form, with input fields for tagging and selecting priorities. There's also an autocomplete dropdown field with a `name` attribute set to "tag_ids_0". However, the most interesting part is the JavaScript variables and functions defined at the end of the code snippet: * `regex`: A regular expression object created using the `/Hello/` pattern. * `prepared_regex`: A new RegExp object created with the 'Hello' string as its pattern. This suggests that the regular expression is being prepared for use. **Benchmark Results** The benchmark results show the execution times of three different JavaScript functions: 1. `regex.test(string)`: This function appears to be executing a test on a regular expression against a given input string. 2. `string.includes("Hello")`: This function checks if a given input string includes the substring "Hello". 3. `string.match("Hello")`: This function searches for a match of a regular expression pattern ("Hello") in a given input string, returning an array of matches or null if no match is found. 4. `prepared_regex.test(string)`: Similar to the first test, this function executes a prepared RegExp object against a given input string. **Observations and Insights** * The test cases cover different aspects of regular expressions and string manipulation in JavaScript. * The benchmark results show that executing `regex.test(string)` takes the longest time compared to the other two functions. This could be due to various factors, such as the complexity of the regex pattern or the specific input strings being tested. * The execution times of `string.includes("Hello")` and `prepared_regex.test(string)` are relatively close, suggesting that the prepared RegExp object might have some performance benefits when used in a test scenario. Without more context about the specific requirements or constraints of this code snippet, it's challenging to provide further insights. However, if you'd like to know how to optimize these functions or improve their performance, I can offer suggestions!
Related benchmarks:
RegEx.test vs. String.includes vs. String.match - 1
RegEx.test vs. String.match vs. String.search
RegEx.test vs. String.includes vs. String.match-Fork
RegEx.test vs. String.includes vs. String.match chitza
RegEx.test vs. String.includes vs. String.match db
Comments
Confirm delete:
Do you really want to delete benchmark?