Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
RegEx.test vs. String.includes vs. String.match for lists
(version: 0)
Comparing performance of:
RegEx.test vs String.includes vs String.match
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var list = [ '0815.ru', '10minutemail.com', '10minutenmail.xyz', '126.com', '1email.eu', '1vbb.de', '20minutemail.com', '24-mail.de', '3d-painting.com', '5x2.de', 'aircln.ru', 'a2mac1', 'anpa.de', 'antichef.net', 'aol.de', 'aol.com', 'arcor.com', 'arcor.de', 'azamat-farisovich.ru', 'beefmilk.com', 'bigcitymail.de', 'bio-muesli.info', 'bio-muesli.net', 'byom.de', 'canineworld.com', 'chattler.de', 'compu-freemail.de', 'cust.in', 'designereasy.ru', 'despammed.com', 'DingBone.com', 'directbox.com', 'directbox.de', 'directbox.net', 'discardmail.com', 'discardmail.de', 'dome-camp.ru', 'dontsendmespam.de', 'eclipso.at', 'eclipso.ch', 'eclipso.com', 'eclipso.de', 'eclipso.eu', 'edv.to', 'email.lu', 'emailias.com', 'emailn.de', 'ero-tube.org', 'exox.de', 'eyepaste.com', 'film-blog.biz', 'firemail.com', 'firemail.de', 'freemail-24.com', 'freemailer.ch', 'freenet.com', 'freenet.de', 'freespin.ru', 'FudgeRub.com', 'geschent.biz', 'gmail.', 'gmx.', 'googlemail.', 'great-host.in', 'guerillamail.org', 'guru.com', 'guru.de', 'h3c.de', 'hotmail.', 'hushmail.com', 'imails.info', 'icloud.com', 'jetable.com', 'k.st', 'k-bg.de', 'kuekomail.net', 'kulturbetrieb.info', 'kurzepost.de', 'live.', 'logomail.com', 'logomail.de', 'LookUgly.com', 'lycos.com', 'lycos.de', 'mail.at', 'mail.com', 'mail.de', 'mail.ru', 'mail1a.de', 'mail4nature.org', 'mail4trash.com', 'mailde.de', 'mailexpire.com', 'maili.com', 'maili.de', 'mailinator.com', 'mailjunky.com', 'mailjunky.de', 'mailnull.com', 'mc-free.com', 'mc-free.de', 'modellraketen.de', 'muellmail.com', 'nervmich.net', 'nervtmich.net', 'nomail2me.com', 'noxamail.de', 'nurfuerspam.de', 'objectmail.com', 'o-taxi31.ru', 'outlook.', 'overmail.com', 'overmail.de', 'owlpic.com', 'oyoony.at', 'oyoony.com', 'oyoony.de', 'oyoony.net', 'pantagor-gel.ru', 'proxymail.eu', 'protonmail.', 'posteo.', 'rcpt.at', 'recode.me', 'rediffmail.com', 's0ny.net', 'sandelf.de', 'saturnbet-official.ru', 'sbdautomotive.com', 'sbdautomotive.de', 'sify.com', 'simbamail.com', 'simbamail.de', 'skymail.at', 'skymail.com', 'skymail.de', 'slucia.com', 'smart-mail.com', 'smart-mail.de', 'SmellFear.com', 'sneakemail.com', 'snkmail.com', 'sofort-mail.de', 'softhome.net', 'spam.la', 'spambog.com', 'spambog.de', 'spambog.ru', 'spamex.com', 'spamfreemail.com', 'spamfreemail.de', 'spamgourmet.com', 'spammotel.com', 'spamtrail.com', 'speed-mailer.com', 'spl.at', 'spoofmail.de', 'squizzy.de', 'streamup.ru', 'super-auswahl.de', 'techmail.com', 'techmail.de', 'teewars.org', 'tempemail.net', 't-online.com', 't-online.de', 'toplinktap.ru', 'trash2009.com', 'trashmail.at', 'trash-mail.at', 'trashmail.com', 'trash-mail.com', 'trashmail.', 'ueberschuss.de', 'uims.com', 'uims.de', 'uni.com', 'uni.de', 'urhen.com', 'usn-dlya-ipe.ru', 'valyutniy-kontrol.ru', 'vcmail.de', 'vpomosmame.ru', 'watchfull.net', 'watch-harry-potter.com', 'web.de', 'wegwerfadresse.de', 'wegwerfemail.de', 'wegwerf-email.net', 'wegwerfemailadresse.com', 'wegwerfmail.de', 'wegwerfmail.net', 'wegwerfmail.org', 'wetacompany.ru', 'willhackforfood.biz', 'wunschdomain.xy', 'x-mail.net', 'yahoo.', 'yandex.', 'yopmail.com', 'zelx.de', 'znam-ya.ru', 'zzrgg.com', 'p3-group.com', 'caresoftglobal.com', ]; var regex = new RegExp( `@(${list.map((d) => d.replace(/[-[\]{}()*+?.,\\/^$|#\s]/g, '\\$&') ).join('|')})` ); var string = 'test123@10minutenmail.xyz';
Tests:
RegEx.test
return regex.test(string);
String.includes
for (var i = 0; i < list.length; i++) { if (string.includes(list[i])) { return true; } } return false;
String.match
return string.match(regex).length > 0;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
RegEx.test
String.includes
String.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):
It looks like we have a set of benchmarking data for three different JavaScript tests: 1. `RegEx.test`: This test uses a regular expression to check if the input string matches a specific pattern. The regex is defined as `@(${list.map((d) => d.replace(/[-[\\]{}()*+?.,\\\\/^$|#\\s]/g, '\\$&')).join('|')})`, where `list` contains a list of domain names. 2. `String.includes`: This test checks if the input string includes any of the values in the `list` array. 3. `String.match`: This test uses a regular expression to match the input string against a pattern defined as `regex`. The latest benchmark results show: * For `RegEx.test`, Chrome 115 on Windows achieves an average of 8,505,132 executions per second. * For `String.match`, Chrome 115 on Windows achieves an average of 728,916.7 executions per second. * For `String.includes`, Chrome 115 on Windows achieves an average of 2,083,700.375 executions per second. It's worth noting that these results are likely to vary depending on the specific system configuration, JavaScript engine version, and other factors. Based on these benchmarking results, we can't make a general conclusion about which test is faster without more context or information about the system configurations used for each test. However, it appears that `String.includes` might be slightly faster than `RegEx.test`, while both are slower than `String.match`.
Related benchmarks:
RegEx.test vs. String.includes vs. String.match insensitive
RegEx.test vs. String.includes vs. String.match (case insensitivee)
RegEx.test vs. String.includes vs. String.match (with multiple strings)
Long regex test vs string includes
Comments
Confirm delete:
Do you really want to delete benchmark?