Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
object-hash SHA-1 encoding 2 excludeKeys hasOwnProperty fix
(version: 1)
Comparing performance of:
Object-hash vs Object-hash excludeKeys
Created:
2 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/object-hash@3.0.0/dist/object_hash.min.js"></script>
Script Preparation code:
var context1 = { title: 'fish', position: 1 }
Tests:
Object-hash
objectHash(context1,{algorithm:'sha1',encoding:'hex'})
Object-hash excludeKeys
objectHash(context1,{algorithm:'sha1',encoding:'hex', excludeKeys(key) { return !context1.hasOwnProperty(key); },})
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Object-hash
Object-hash excludeKeys
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/123.0.0.0 Safari/537.36
Browser/OS:
Chrome 123 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Object-hash
43859.8 Ops/sec
Object-hash excludeKeys
141492.4 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the benchmark for you. **Benchmark Overview** MeasureThat.net is used to create and run JavaScript microbenchmarks. The provided JSON represents two individual test cases, each testing different aspects of the `objectHash` function. **Script Preparation Code** The script preparation code provides a basic object `context1` with two properties: `title` and `position`. **Html Preparation Code** The HTML preparation code includes a script tag that loads the `object-hash` library (version 3.0.0) from a CDN. This library is used to perform SHA-1 encoding of objects. **Benchmark Definition JSON** There are two benchmark definitions: 1. `"objectHash(context1,{algorithm:'sha1',encoding:'hex'})"` This test case measures the execution time of the `objectHash` function with the following parameters: * `context`: The `context1` object created in the script preparation code. * `algorithm`: 'sha1' (SHA-1 hashing algorithm). * `encoding`: 'hex' (encoding output as a hexadecimal string). 2. `"objectHash(context1,{algorithm:'sha1',encoding:'hex',excludeKeys(key) {\r\n return !context1.hasOwnProperty(key);\r\n },})"` This test case measures the execution time of the `objectHash` function with an additional `excludeKeys` property: * The same parameters as above. * `excludeKeys`: A function that takes a key and returns `true` if the key is not present in the `context1` object using the `hasOwnProperty` method. **Options Comparison** There are two main options being compared: 1. **Encoding Output**: The first benchmark definition uses 'hex' encoding, while the second test case uses an additional `excludeKeys` property with a function that excludes keys from the hash. 2. **Key Exclusion**: The second test case includes an `excludeKeys` property that filters out specific keys from the hash using the `hasOwnProperty` method. **Pros and Cons** 1. **Encoding Output (hex vs other encodings)**: * 'hex' encoding is a common and widely supported format. * Using other encodings (e.g., base64) might be more efficient but may not be as widely supported. 2. **Key Exclusion (using `hasOwnProperty` vs custom filter)**: * The `hasOwnProperty` method is a safe and efficient way to exclude keys, but it may introduce additional overhead. * A custom filter function can provide more control over which keys are excluded, but may be slower or more memory-intensive. **Library: object-hash** The `object-hash` library provides the `objectHash` function used in these benchmarks. It is designed to perform SHA-1 encoding of objects and provides various options for customization, such as encoding format and key exclusion. **Special JS Feature/Syntax: none mentioned** There are no special JavaScript features or syntax being tested in these benchmarks. **Alternatives** If you wanted to create a similar benchmark using a different library or approach: * You could use the `crypto` API on the client-side to perform SHA-1 encoding. * Alternatively, you might consider using a library like `js-sha256` for SHA-1 hashing. * For key exclusion, you could implement a custom filter function using the `Object.keys()` method and a `for...of` loop. Keep in mind that these alternatives would likely have different performance characteristics and requirements compared to the `object-hash` library.
Related benchmarks:
21dsfsdfasdf
object-hash SHA-1 vs MD5 vs passthrough
object-hash SHA-1 encoding 2
hash-sum vs object-hash opttimized 2
Comments
Confirm delete:
Do you really want to delete benchmark?