Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
FP vs OOP formatting implementation
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Browser:
Chrome 138
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
10 months ago
Test name
Executions per second
OOP
70981.3 Ops/sec
FP
78756.1 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const input = { price: '1234.567890' }; const locale = 'en-US'; const options = { style: 'currency', currency: 'USD' }; window.benchmarkConfig = { input, locale, options }
Tests:
OOP
class BaseFormatter { constructor(locale) { this.locale = locale; } formatPrice(input, options) { const rawValue = parseFloat(input); const formatter = new Intl.NumberFormat(this.locale, options); return formatter.format(rawValue); } } class OrderBookFormatter extends BaseFormatter { format(input) { return { price: this.formatPrice(input.price, window.benchmarkConfig.options), }; } } const oopFormatter = new OrderBookFormatter(window.benchmarkConfig.locale); oopFormatter.format(window.benchmarkConfig.input)
FP
const formatPrice = (input, { locale, options }) => { const rawValue = parseFloat(input); const formatter = new Intl.NumberFormat(locale, options); return formatter.format(rawValue); }; const createOrderBookFormatter = (locale) => { return (input) => { return { price: formatPrice(input.price, { locale, options: window.benchmarkConfig.options }), }; }; }; const fpFormatter = createOrderBookFormatter(window.benchmarkConfig.locale); fpFormatter(window.benchmarkConfig.input)