Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Comparison between replace and split map join with Map 222
(version: 0)
Comparing performance of:
split map join vs split map join Map vs loop Map vs loop
Created:
7 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
const defaultSubs = { '1': 'i', '0': 'o', '5': 's', '9': 'g', '6': 'b', '7': 't', // eslint-disable-line '3': 'e', '+': 't', '$': 's', '^': 'n', '|': 'i', 'А': 'a', // eslint-disable-line 'Б': 'b', 'В': 'b', 'Г': 'r', 'Ґ': 'r', 'Д': 'a', 'Ђ': 'h', // eslint-disable-line 'Ѓ': 'r', 'Е': 'e', 'Ё': 'e', 'Є': 'c', 'ç': 'c', 'û': 'u', // eslint-disable-line 'Ж': 'x', 'З': 'e', 'З́': 'e', 'Ѕ': 's', 'И': 'n', 'І': 'i', // eslint-disable-line 'Ї': 'i', 'Й': 'n', 'Ј': 'j', 'К': 'k', 'Л': 'n', 'Љ': 'b', // eslint-disable-line 'М': 'm', 'Н': 'h', 'Њ': 'h', 'О': 'o', 'Р': 'p', 'С': 'c', // eslint-disable-line 'С́': 'c', 'Т': 't', 'Ћ': 'h', 'Ќ': 'k', 'У': 'y', 'Ў': 'y', // eslint-disable-line 'Ф': 'o', 'Х': 'x', 'Ц': 'u', 'Ч': 'y', 'Џ': 'u', 'Ш': 'w', // eslint-disable-line 'Щ': 'w', 'Ъ': 'b', 'Ы': 'bl','Ь': 'b', 'Э': 'e', 'Ю': 'io', // eslint-disable-line 'Я': 'r', 'Ӏ': 'i', 'Ә': 'b', 'Ғ': 'r', 'Ҙ': 'e', 'Ҫ': 'c', // eslint-disable-line 'Ҡ': 'k', 'Җ': 'x', 'Қ': 'k', 'Ң': 'h', 'Ҥ': 'h', 'Ө': 'o', // eslint-disable-line 'Ү': 'y', 'Ұ': 'y', 'Һ': 'h', 'Ҳ': 'x', 'Α': 'a', 'α': 'a', // eslint-disable-line 'Β': 'b', 'β': 'b', 'Γ': 'r', 'γ': 'y', 'Δ': 'a', 'δ': 'o', // eslint-disable-line 'Ε': 'e', 'ε': 'e', 'Ο': 'o', 'ο': 'o', 'Π': 'n', 'π': 'n', // eslint-disable-line 'Ρ': 'p', 'ρ': 'p', 'Σ': 'e', 'σ': 'o', 'ς': 'c', 'Τ': 't', // eslint-disable-line 'τ': 't', 'Υ': 'y', 'υ': 'u', 'Φ': 'o', 'φ': 'o', 'Χ': 'x', // eslint-disable-line 'χ': 'x', 'Ψ': 'w', 'ψ': 'w', 'Ω': 'o', 'ω': 'w', '@': 'a', // eslint-disable-line '4': 'a' }; const defaultSubs2 = new Map(JSON.parse('[["0","o"],["1","i"],["3","e"],["4","a"],["5","s"],["6","b"],["7","t"],["9","g"],["+","t"],["$","s"],["^","n"],["|","i"],["А","a"],["Б","b"],["В","b"],["Г","r"],["Ґ","r"],["Д","a"],["Ђ","h"],["Ѓ","r"],["Е","e"],["Ё","e"],["Є","c"],["ç","c"],["û","u"],["Ж","x"],["З","e"],["З́","e"],["Ѕ","s"],["И","n"],["І","i"],["Ї","i"],["Й","n"],["Ј","j"],["К","k"],["Л","n"],["Љ","b"],["М","m"],["Н","h"],["Њ","h"],["О","o"],["Р","p"],["С","c"],["С́","c"],["Т","t"],["Ћ","h"],["Ќ","k"],["У","y"],["Ў","y"],["Ф","o"],["Х","x"],["Ц","u"],["Ч","y"],["Џ","u"],["Ш","w"],["Щ","w"],["Ъ","b"],["Ы","bl"],["Ь","b"],["Э","e"],["Ю","io"],["Я","r"],["Ӏ","i"],["Ә","b"],["Ғ","r"],["Ҙ","e"],["Ҫ","c"],["Ҡ","k"],["Җ","x"],["Қ","k"],["Ң","h"],["Ҥ","h"],["Ө","o"],["Ү","y"],["Ұ","y"],["Һ","h"],["Ҳ","x"],["Α","a"],["α","a"],["Β","b"],["β","b"],["Γ","r"],["γ","y"],["Δ","a"],["δ","o"],["Ε","e"],["ε","e"],["Ο","o"],["ο","o"],["Π","n"],["π","n"],["Ρ","p"],["ρ","p"],["Σ","e"],["σ","o"],["ς","c"],["Τ","t"],["τ","t"],["Υ","y"],["υ","u"],["Φ","o"],["φ","o"],["Χ","x"],["χ","x"],["Ψ","w"],["ψ","w"],["Ω","o"],["ω","w"],["@","a"]]')) function replace1(str) { const keys = Object.keys(defaultSubs); let content = str for (let i = 0; i < keys.length; i += 1) { content = str.replace(keys[i], defaultSubs[keys[i]]); } return content } function replace2(str) { return str.split('').map(x => defaultSubs[x] !== undefined ? defaultSubs[x] : x).join('') } function replace3(str) { return str.split('').map(x => defaultSubs2.get(x) !== undefined ? defaultSubs2.get(x) : x).join('') } function replace4(str) { let content = str for (const keya of defaultSubs2.keys()) { content = str.replace(keya, defaultSubs2.get(keya)); } return content }
Tests:
split map join
replace2('@n1m4710n n199@ 6199g4')
split map join Map
replace3('@n1m4710n n199@ 6199g4')
loop Map
replace4('@n1m4710n n199@ 6199g4')
loop
replace1('@n1m4710n n199@ 6199g4')
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
split map join
split map join Map
loop Map
loop
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 do my best to help you out. It appears that we have a JavaScript code snippet with several functions, including `replace1`, `replace2`, `replace3`, and `replace4`. These functions are used for string replacement in a specific context. I notice that there are two sets of substitutions defined: one using an object (`defaultSubs`) and another using a Map (`defaultSubs2`). The test cases provided seem to be benchmarking the performance of these four functions on different inputs, specifically the string `@n1m4710n n199@ 6199g4`. The benchmark results are displayed in a format that shows the browser type, device platform, operating system, executions per second, and the corresponding test name. My question is: What is the expected output or behavior of these functions, and what insights can be gained from the provided benchmark results?
Related benchmarks:
Comparison between replace and split map join
Comparison between replace and split map join with Map
Comparison between replace and split map join test2
Diacritics removal (+ lowercase2)
Comments
Confirm delete:
Do you really want to delete benchmark?