Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Better number parsing
(version: 0)
Comparing performance of:
Betterparse type 1 vs Betterparse type 2 vs Standard parsing (incorrect) vs Standard parsing 2 (incorrect) vs Betterparse type 3
Created:
3 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var betterparse1 = (s) => { // special case handling of literal "nan" values s = s.toLowerCase() if (s === "nan" || s === "-nan" || s === "+nan") return NaN; const v = Number(s); if (isNaN(v)) return null; return v; // guaranteed to be a number that isn't NaN (but it could be Infinity) } var betterparse2 = (s) => { // special case handling of literal "nan" values switch (s.toLowerCase()) { case "nan": case "+nan": case "-nan": return NaN; } const v = Number(s); if (isNaN(v)) return null; return v; // guaranteed to be a number that isn't NaN (but it could be Infinity) } var betterparse3 = (s) => { switch (s) { case "nan": case "+nan": case "-nan": case "NaN": case "+NaN": case "-NaN": case "NAN": case "+NAN": case "-NAN": return NaN; } const v = Number(s); if (isNaN(v)) return null; return v; // guaranteed to be a number that isn't NaN (but it could be Infinity) } var numbers = [ "0.327257347992157", "0.03432947163666622", "0.19054570522014136", "0.757924325036481", "0.8756495827150409a", "0.8735223786857549", "0.16193166094499645", "0.3264840252931367", "0.8976069804818312", "0.05823493932681134", "0.9467170087775896", "-NAN", "0.3411182773746414", "0.04273697798010612", "0.4599136076509416", "0.20091841618072792", "0.7481790478470371", "0.631090589202488", "0.6134529272259946", "0.7603019894148221", "NaN", "0.6848452952886251", "0.8958221077246171", "0.25265763361084415", "0.31674875667294267", "0.6097282060031768", "0.18265134080263656", "", "0.36918250030559796", "0.6053164008875728", "0.39730683023873337", "0.3842390211966774", "0.5573411172870547", "b0.9682358615780161", "0.8304492155340027", "0.1464933423860405", "0.26340608593749726", "0.22961410590320552", "0.5908943588693252", "0.9002256812711459", "0.8092150249145922", "0.060955373278098635", "0.04253202590541827", "0.4994387689297176", "0.05581701909464065", "0.01981156164547493", "0.12833340391640402", "NaN", "0.465050111507027", "0.7636969664726854", "0.12864577854450943", "0.47847392755062357", "0.09313181128668402", "0.9473000507174908", "0.869188703023482", "0.8476349098291822", "0.5060602000203033", "0.013594390816120128", "NaN", "0.7159481390807573", "0.9785693256013818", "0.6567281886346458", "0.2741853723406986", "0.08134454100211075", "0.16720862159533767", "0.043608322437359126", "NaN", "0.7552857256174752", "0.10191443424045554", "0.6683869703195341", "0.1672931087637095", "0.029535244526663784", "+nan", "0.9038827319929565", "0.9580917987405422", "0.33091435472002173", "0.6400233200277594", "dfsgsegrsert", "0.39558554444217287", "0.6817925156801317", "0.7543418101559722", "0.8112443776211025", "0.4746963996832825", "0.4970739670176436", "0.6522344216702008", "0.37851252385904544", "0.9145354809581934", "0.17983840765587844", "0.5632683939437284", "0.2581147343499265", "0.5593935878390675", "0.14874151599102725", "0.32513087795909557", "0.253zxxxzz77838496", "0.9299155933721135", "0.7609785538234373", "0.6181474622979708", "0.9775946358910067", "0.07623977301767593", "0.7534482258293359", ];
Tests:
Betterparse type 1
let x; for (const s of numbers) { x = betterparse1(s); }
Betterparse type 2
let x; for (const s of numbers) { x = betterparse2(s); }
Standard parsing (incorrect)
let x; for (const s of numbers) { x = Number(s); }
Standard parsing 2 (incorrect)
let x; for (const s of numbers) { x = parseFloat(s); }
Betterparse type 3
let x; for (const s of numbers) { x = betterparse2(s); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
Betterparse type 1
Betterparse type 2
Standard parsing (incorrect)
Standard parsing 2 (incorrect)
Betterparse type 3
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 appears that you are providing a JSON object containing benchmarking results and test cases, but it's not clear what specific problem or question you're trying to ask. The JSON object includes: * A list of numbers (`numbers`) with 12 elements * An HTML snippet with "Html Preparation Code": null * Individual test cases with benchmark definitions and test names (e.g. "Betterparse type 1", etc.) * Latest benchmark result with multiple entries for different browsers, devices, and platforms Can you please clarify or provide more context about what you're trying to accomplish or ask? I'll do my best to help!
Related benchmarks:
Ramda vs. Lodash 2
Ramda vs. Lodash 3
Ramda vs. Lodash mmm
Ramda vs. Lodash correct
Ramda vs. Lodash v2
Comments
Confirm delete:
Do you really want to delete benchmark?