Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Dexie init
(version: 0)
Comparing performance of:
no cache vs with caching
Created:
6 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://unpkg.com/dexie@latest/dist/dexie.js"></script> <script> const getDb = () => { const skDatabase = new Dexie('skDatabase') skDatabase.version(1).stores({ communications: '++id' }) return skDatabase }; const getDbWithCaching = (() => { const db = getDb() return () => { return db } })(); </script>
Tests:
no cache
getDb();
with caching
getDbWithCaching();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
no cache
with caching
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
7 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Browser/OS:
Chrome 141 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
no cache
43870.2 Ops/sec
with caching
147632288.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark definition and test cases. **Benchmark Definition:** The provided JSON represents a JavaScript microbenchmark that tests the initialization of the Dexie library, a popular offline database for web applications. **Script Preparation Code:** The script preparation code is a minimal setup to include the Dexie library in the HTML file: ```html <script src="https://unpkg.com/dexie@latest/dist/dexie.js"></script> ``` This script includes the latest version of the Dexie library, which provides an asynchronous API for interacting with databases. The actual initialization code is defined in a separate JavaScript block: ```javascript const getDb = () => { const skDatabase = new Dexie('skDatabase'); skDatabase.version(1).stores({ communications: '++id' }); return skDatabase; }; const getDbWithCaching = (() => { const db = getDb(); return () => { return db; }; })(); // Note the immediately invoked function expression (IIFE) for caching ``` The `getDb()` function creates a new instance of the Dexie database, while `getDbWithCaching` returns the same instance wrapped in an IIFE. The latter is used to cache the result of `getDb()`, allowing subsequent calls to reuse the cached instance. **Test Cases:** There are two test cases: 1. **"no cache"**: This test case measures the execution time of calling `getDb()` directly without caching. 2. **"with caching"**: This test case measures the execution time of calling `getDbWithCaching()`, which uses caching to reuse the result of `getDb()`. **Options Compared:** The two test cases compare the performance difference between using caching (via IIFE) and not using caching (by directly calling `getDb()`). **Pros and Cons:** * **Caching (via IIFE):** + Pros: - Reuses the result of `getDb()`, reducing overhead. - Can improve performance for repeated calls to `getDb()`. + Cons: - Adds a layer of complexity with the IIFE, which may introduce unnecessary overhead. - May not be beneficial if `getDb()` is called only once or rarely. * **No caching (direct call):** + Pros: - Simpler and more straightforward implementation. - No added overhead from the IIFE. + Cons: - Requires multiple calls to `getDb()` for repeated use, increasing overhead. **Library:** The Dexie library is a lightweight JavaScript framework for offline databases. Its purpose is to provide an asynchronous API for interacting with local storage or other data sources, allowing web applications to store and retrieve data even when the user is offline. **Special JS Features/Syntax:** * Immediately Invoked Function Expression (IIFE): Used in `getDbWithCaching` to create a cached version of `getDb()`. This syntax is used to execute the function immediately after its definition. * Arrow Functions (`=>`): Used in `getDb()` and `getDbWithCaching` for concise function definitions. **Alternatives:** For offline databases, other popular alternatives include: 1. IndexedDB 2. PouchDB 3. LocalStorage These libraries offer similar functionality to Dexie but with different approaches and features.
Related benchmarks:
Fly Json ODM - 1.18.2 - Query Performance
Fly Json ODM - 1.19.0 - Query Performance
Fly Json ODM - 1.20.0 - Query Performance
Fly Json ODM - 1.21.0 - Query Performance
Usporedba Optimised 10
Comments
Confirm delete:
Do you really want to delete benchmark?