Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
map filter vs RegExp without console.log
(version: 0)
Comparing performance of:
== vs === vs RegExp newString vs RegExp copy
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<div id=''></div>
Script Preparation code:
window.mockQueries = { articles: ` query GetArticles($first: Int!, $after: String) { articles(first: $first, after: $after) { pageInfo { hasNextPage } edges { cursor node { author { bio email firstName lastName name } blog { id } comments(first: 250) { edges { node { author { email name } content contentHtml id } } } content contentHtml excerpt excerptHtml handle id handle image { altText id src } publishedAt tags title url seo { title description } } } } } `, blogs: ` query GetBlogs($first: Int!, $after: String) { blogs(first: $first, after: $after) { pageInfo { hasNextPage } edges { cursor node { handle id handle title url } } } } `, collections: ` query GetCollections($first: Int!, $after: String) { collections(first: $first, after: $after) { pageInfo { hasNextPage } edges { cursor node { description descriptionHtml handle id image { altText id src } products(first: 250) { edges { node { id } } } title updatedAt } } } } `, products: ` query GetProducts($first: Int!, $after: String) { products(first: $first, after: $after) { pageInfo { hasNextPage } edges { cursor node { availableForSale createdAt description descriptionHtml handle id images(first: 250) { edges { node { id altText originalSrc } } } metafields(first: 250) { edges { node { description id key namespace value valueType } } } onlineStoreUrl options { id name values } priceRange { minVariantPrice { amount currencyCode } maxVariantPrice { amount currencyCode } } productType publishedAt tags title updatedAt variants(first: 250) { edges { node { availableForSale compareAtPrice compareAtPriceV2 { amount currencyCode } id image { altText id originalSrc } metafields(first: 250) { edges { node { description id key namespace value valueType } } } price priceV2 { amount currencyCode } requiresShipping selectedOptions { name value } sku title weight weightUnit presentmentPrices(first: 250) { edges { node { price { amount currencyCode } compareAtPrice { amount currencyCode } } } } } } } vendor } } } } `, shopPolicies: ` query GetPolicies { shop { privacyPolicy { body handle id title url } refundPolicy { body handle id title url } termsOfService { body handle id title url } } } `, pages: ` query GetPages($first: Int!, $after: String) { pages(first: $first, after: $after) { pageInfo { hasNextPage } edges { cursor node { id handle title body bodySummary updatedAt url } } } } `, } window.testStringsNewString = Object.entries(window.mockQueries).map(([queryName, queryString]) => new String(queryString)) window.testStringsCopy = Object.entries(window.mockQueries).map(([queryName, queryString]) => queryString)
Tests:
==
const testStrings = window.testStringsNewString const mockQueries = window.mockQueries const fixturePathFromQuery = (query, mockQueries) => { const [queryName] = Object.entries(mockQueries).find( ([queryName, queryString]) => queryString == query ) return queryName + `.json` } var result = testStrings.map(t => fixturePathFromQuery(t, mockQueries))
===
const testStrings = window.testStringsCopy const mockQueries = window.mockQueries const fixturePathFromQuery = (query, mockQueries) => { const [queryName] = Object.entries(mockQueries).find( ([queryName, queryString]) => queryString === query ) return queryName + `.json` } var result = testStrings.map(t => fixturePathFromQuery(t, mockQueries))
RegExp newString
const testStrings = window.testStringsNewString const mockQueries = window.mockQueries const test = new RegExp(/query Get(\w*)/) const fixturePathFromQuery = (query) => { const queryName = test.exec(query)[1].toLowerCase() return queryName + `.json` } var result = testStrings.map(t => fixturePathFromQuery(t))
RegExp copy
const testStrings = window.testStringsCopy const mockQueries = window.mockQueries const test = new RegExp(/query Get(\w*)/) const fixturePathFromQuery = (query) => { const queryName = test.exec(query)[1].toLowerCase() return queryName + `.json` } var result = testStrings.map(t => fixturePathFromQuery(t))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
==
===
RegExp newString
RegExp copy
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):
The task is to determine which of the provided benchmark test cases, comparing different implementations of `fixturePathFromQuery`, will result in the fastest execution time. Based on the benchmark results, it appears that: * The "RegExp copy" test case has the highest executions per second (488685.625), indicating a faster execution time. * The "RegExp newString" test case is slower than the "RegExp copy" test case but still relatively fast (127805.40625). * The two "==" tests are significantly slower (370424.46875 and 99907.9453125 executions per second). Therefore, it can be concluded that the "RegExp copy" test case will result in the fastest execution time among the provided benchmark test cases.
Related benchmarks:
endsWith() vs regex
Regexp vs. Includes vs. IndexOf
includes vs regex 3 terms
List includes lookup
startsWith vs regex hash
Comments
Confirm delete:
Do you really want to delete benchmark?