Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
console-19281589175831
(version: 0)
Comparing performance of:
action vs actionWithLog vs actionWithLogData vs actionWithCustomLog
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
const counter = { val: 0 }; function action() { counter.val++; } function actionWithLog() { counter.val++; console.log('ok'); } function actionWithLogData() { counter.val++; console.log('ok', counter); } const customLog = []; function actionWithCustomLog() { counter.val++; customLog.push(['ok', {...counter}]); }
Tests:
action
action();
actionWithLog
actionWithLog();
actionWithLogData
actionWithLogData();
actionWithCustomLog
actionWithCustomLog()
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
action
actionWithLog
actionWithLogData
actionWithCustomLog
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0
Browser/OS:
Firefox 124 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
action
686780352.0 Ops/sec
actionWithLog
65731.2 Ops/sec
actionWithLogData
56033.8 Ops/sec
actionWithCustomLog
5026856.5 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the details of this benchmark. **What is being tested?** The provided JSON represents four JavaScript microbenchmarks: 1. `action()`: This function simply increments a counter variable (`counter.val`) and does nothing else. 2. `actionWithLog()`: Similar to `action()`, but also logs "ok" to the console using `console.log()`. 3. `actionWithLogData()`: Also increments the counter and logs "ok" followed by the current state of the counter object (`counter`) using `console.log()`. 4. `actionWithCustomLog()`: Similar to `actionWithLog()`, but instead of logging to the console, it pushes an array with the string "ok" and a copy of the `counter` object to an external log variable (`customLog`). **Options being compared** The four test cases are comparing different approaches to incrementing a counter variable: * `action()` vs. `actionWithLog()`: Does logging affect performance? * `action()` vs. `actionWithLogData()`: Does logging the current state of the object impact performance? * `action()` vs. `actionWithCustomLog()`: How does storing log data in an external array compare to logging directly to the console? **Pros and Cons** 1. **Logging (`actionWithLog`)**: * Pros: Easy to read and analyze log output. * Cons: May introduce additional overhead due to function calls and object creation. 2. **Logging with object state (`actionWithLogData`)**: * Pros: Provides more insight into the counter's state at a specific point in time. * Cons: May increase memory usage due to object cloning and logging. 3. **External log storage (`actionWithCustomLog`)**: * Pros: Can be optimized for performance by using a fixed-size buffer or caching. * Cons: Requires careful management of the log buffer to avoid memory leaks. **Special considerations** The test cases use some standard JavaScript features, including: * Object literals and assignment * Function declarations and calls * `console.log()` statements There are no notable special features or syntax used in these benchmarks. **Alternatives** If you wanted to create a similar benchmark, you could consider adding more test cases that explore additional scenarios, such as: * Using a different logging mechanism (e.g., console.error(), file output) * Increasing the complexity of the log data being logged * Using asynchronous logging or callbacks * Exploring performance differences on different platforms or browsers Keep in mind that each added test case would require more code and potentially increase the benchmark's overall overhead.
Related benchmarks:
with loggingbut better
console log benchmark
console-1928158917583
new Function() vs native
Comments
Confirm delete:
Do you really want to delete benchmark?