Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Creating Date objects 350 vs 9000
(version: 0)
Checking how 350 Date object creations compares to 9000
Comparing performance of:
350 object creations vs 9000 object creations
Created:
one year ago
by:
Guest
Jump to the latest result
Tests:
350 object creations
function parseMyDate() { const dateString = "2024-05-31T09:13:43.095Z"; if (/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(dateString)) { dateString += 'Z'; } const result = Date.parse(dateString); return isNaN(result) ? null : (result / 1000.0); } for (var i=0; i<350; i++) { parseMyDate(); }
9000 object creations
function parseMyDate() { const dateString = "2024-05-31T09:13:43.095Z"; if (/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(dateString)) { dateString += 'Z'; } const result = Date.parse(dateString); return isNaN(result) ? null : (result / 1000.0); } for (var i=0; i<9000; i++) { parseMyDate(); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
350 object creations
9000 object creations
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3.1 Safari/605.1.15
Browser/OS:
Safari 17 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
350 object creations
27368.3 Ops/sec
9000 object creations
1063.5 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
The test measures the performance difference between creating 350 Date objects versus 9000 Date objects in JavaScript. The two options being compared are: 1. Creating 350 Date objects: * Pros: This option is more manageable and easier to implement, as it involves fewer iterations. * Cons: It may not accurately represent real-world scenarios where large numbers of Date object creations are required. 2. Creating 9000 Date objects: * Pros: This option more closely mimics real-world use cases where large quantities of Date objects need to be created, such as in data processing or analytics applications. * Cons: It involves more iterations and may be computationally intensive. The test case uses the `Date` object, which is a built-in JavaScript object that represents a specific point in time. The purpose of the `Date` object is to provide a convenient way to work with dates and times in JavaScript. In this specific benchmark definition, the `parseMyDate()` function is used to create Date objects. This function takes a date string as input, parses it, and returns the corresponding Date object. The `Date.parse()` method is used to parse the date string into a number representing the timestamp of the specified date and time. The test case uses regular expressions (`/^\\d+-\\d+-\\d+T\\d+:\\d+:\\d+(\\.\\d+)?$/`) to validate the input date strings. This ensures that only valid date strings are passed to the `Date.parse()` method. Other alternatives to creating Date objects could include using libraries like Moment.js or Luxon, which provide more advanced date and time manipulation capabilities. However, for simple use cases, the built-in JavaScript `Date` object is sufficient. The benchmark results show that Safari 17 on a Mac OS X 10.15.7 desktop performed better on the smaller dataset (350 objects), while performing similarly or slightly worse on the larger dataset (9000 objects).
Related benchmarks:
Date.parse vs new Date in milliseconds
new Date from UNIX timestamp vs new Date from ISO string
new Date from UNIX timestamp (ms) vs new Date from ISO string
Date clone test
Instanceof VS toString for date comparison when using objects
Comments
Confirm delete:
Do you really want to delete benchmark?