Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
caching vs no cachink ye
(version: 0)
Comparing performance of:
no chace vs with cache
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var objectString = { "reportActions_1234": { action: "view", timestamp: "2024-07-17T10:15:30Z", user: "JohnDoe" }, "reportActions_5678": { action: "edit", timestamp: "2024-07-17T11:20:45Z", user: "JaneSmith" }, "reportActions_91011": { action: "delete", timestamp: "2024-07-17T12:25:50Z", user: "AlexJohnson" }, "reportActions_1213": { action: "create", timestamp: "2024-07-17T13:30:55Z", user: "EmilyBrown" }, "reportActions_1415": { action: "share", timestamp: "2024-07-17T14:35:00Z", user: "ChrisDavis" }, "reportActions_1235": { action: "view", timestamp: "2024-07-17T10:15:30Z", user: "JohnDoe" }, "reportActions_5679": { action: "edit", timestamp: "2024-07-17T11:20:45Z", user: "JaneSmith" }, "reportActions_91021": { action: "delete", timestamp: "2024-07-17T12:25:50Z", user: "AlexJohnson" }, "reportActions_1214": { action: "create", timestamp: "2024-07-17T13:30:55Z", user: "EmilyBrown" }, "reportActions_1416": { action: "share", timestamp: "2024-07-17T14:35:00Z", user: "ChrisDavis" }, "report_1234": { action: "view", timestamp: "2024-07-17T10:15:30Z", user: "JohnDoe" }, "report_5678": { action: "edit", timestamp: "2024-07-17T11:20:45Z", user: "JaneSmith" }, "report_91011": { action: "delete", timestamp: "2024-07-17T12:25:50Z", user: "AlexJohnson" }, "report_1213": { action: "create", timestamp: "2024-07-17T13:30:55Z", user: "EmilyBrown" }, "report_1415": { action: "share", timestamp: "2024-07-17T14:35:00Z", user: "ChrisDavis" }, "report_1235": { action: "view", timestamp: "2024-07-17T10:15:30Z", user: "JohnDoe" }, "report_5679": { action: "edit", timestamp: "2024-07-17T11:20:45Z", user: "JaneSmith" }, "report_91021": { action: "delete", timestamp: "2024-07-17T12:25:50Z", user: "AlexJohnson" }, "report_1214": { action: "create", timestamp: "2024-07-17T13:30:55Z", user: "EmilyBrown" }, "report_1416": { action: "share", timestamp: "2024-07-17T14:35:00Z", user: "ChrisDavis" } }; var reportActionIds = [ "1234", "5678", "91011", "1213", "1415", "1235", "5679", "91021", "1214", "1416" ]; var reportIds = [ "1234", "5678", "91011", "1213", "1415", "1235", "5679", "91021", "1214", "1416" ];
Tests:
no chace
function getString(collection, id) { return `${collection}${id}`; } for (let i of reportActionIds) { objectString[getString("reportActions_", i)]; } for (let i of reportIds) { objectString[getString("report_", i)]; } for (let i of reportActionIds) { objectString[getString("reportActions_", i)]; } for (let i of reportIds) { objectString[getString("report_", i)]; }
with cache
const cache = {}; function getString(collection, id) { if (!cache[collection]) { cache[collection] = {}; } if (cache[collection][id]) { return cache[collection][id]; } cache[collection][id] = `${collection}${id}`; return cache[collection][id]; } for (let i of reportActionIds) { objectString[getString("reportActions_", i)]; } for (let i of reportIds) { objectString[getString("report_", i)]; } for (let i of reportActionIds) { objectString[getString("reportActions_", i)]; } for (let i of reportIds) { objectString[getString("report_", i)]; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
no chace
with cache
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/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Browser/OS:
Chrome 126 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
no chace
281081.4 Ops/sec
with cache
170673.9 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark and explain what's being tested. **What is the benchmark testing?** The benchmark is testing two different ways of retrieving values from an object using string concatenation. The test cases are: 1. **"no cache"**: This test case uses a simple string concatenation approach without any caching mechanism. 2. **"with cache"**: This test case uses a caching mechanism to store retrieved values, so that subsequent requests for the same value can be served from memory instead of recalculating it. **What's happening in the benchmark?** The benchmark consists of two loops: 1. The first loop iterates over `reportActionIds` and constructs strings like "reportActions_<id>" using the `getString` function. 2. The second loop iterates over `reportIds` and constructs strings like "report_<id>" using the same `getString` function. In both test cases, these loops are repeated multiple times to simulate a large number of requests. **What's being measured?** The benchmark is measuring the execution time (in seconds) it takes to complete the two loops. The raw execution time is reported in the "ExecutionsPerSecond" column. **What does the latest benchmark result mean?** According to the latest benchmark result, the **"no cache"** test case completes 281081.375 executions per second on a Chrome 126 browser on a Mac OS X 10.15.7 desktop, while the **"with cache"** test case completes 170673.875 executions per second. This suggests that using caching (the "with cache" approach) reduces the execution time by approximately 39% compared to not using caching (the "no cache" approach). In general, this benchmark is testing the trade-off between performance and memory usage when implementing string concatenation in JavaScript applications. The caching mechanism can help improve performance at the cost of increased memory usage.
Related benchmarks:
delete vs spread without vs spread override
delete vs spread need for speed
string interpolation vs direct access
caching string interpolation vs not
Comments
Confirm delete:
Do you really want to delete benchmark?