Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array cache
(version: 0)
Comparing performance of:
cached vs uncached
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
cached
const array = []; for (let i=0; i<1000; i++) { for (let j=0; j<1000; j++) { array[i * 1000 + j] = 0; } }
uncached
const array = []; for (let i=0; i<1000; i++) { for (let j=0; j<1000; j++) { array[j * 1000 + i] = 0; } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
cached
uncached
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Browser/OS:
Chrome 119 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
cached
61.1 Ops/sec
uncached
17.3 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of JavaScript microbenchmarks on MeasureThat.net. The provided JSON represents a benchmark definition, which defines a simple array cache operation. The test case consists of two variants: **Benchmark Definition** The benchmark is defined by a script preparation code and an HTML preparation code (both are empty in this case). The script preparation code simply initializes an empty array `const array = [];`. There are no special JavaScript features or syntax used in the benchmark definition. **Test Cases** There are two test cases: 1. **`cached`**: This test case uses the `array[i * 1000 + j] = 0;` assignment pattern, where each element is assigned a value using an index that depends on both `i` and `j`. This means that the array's elements are filled in a way that minimizes cache locality. 2. **`uncached`**: This test case uses the `array[j * 1000 + i] = 0;` assignment pattern, where each element is assigned a value using an index that depends on both `j` and `i`. This means that the array's elements are filled in a way that minimizes cache coherence. **Comparison** The two test cases are designed to compare the performance of the array cache operation with different memory access patterns. The `cached` variant uses a pattern that is known to be more efficient for caching, as it allows the CPU to access contiguous blocks of data in the cache hierarchy. In contrast, the `uncached` variant uses a pattern that can lead to more cache misses. **Pros and Cons** * **`cached`**: + Pros: Optimized for caching, potentially faster execution times. + Cons: May not be optimal for other scenarios where cache coherence is important. * **`uncached`**: + Pros: More flexible and adaptable to different use cases, potentially better performance in some scenarios. + Cons: May result in slower execution times due to reduced caching. **Library and Features** There are no libraries used in this benchmark definition. No special JavaScript features or syntax are employed. **Alternatives** Other alternatives for testing array cache operations might include: * Testing different data types (e.g., strings, numbers) instead of integers. * Using a larger array size to increase the number of cache misses. * Implementing different caching strategies (e.g., LRU, LFU). * Comparing the performance of different JavaScript engines or implementations. Overall, this benchmark is designed to provide insight into the performance characteristics of array cache operations with different memory access patterns.
Related benchmarks:
Ringbuffer array vs Float64Array
Array.sort vs Array.map
Array.sort vs Array.map x2
Array.sort vs Array.map x1
Array.sort 1 vs Array.map x1
Comments
Confirm delete:
Do you really want to delete benchmark?