<script src="https://cdn.jsdelivr.net/npm/hash-sum@2.0.0/hash-sum.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/object-hash@2.0.3/dist/object_hash.min.js"></script>
var v1 = {
"id": "4dd64046-b51a-4b4f-9a07-ca9219aeaa97",
"cardId": "a842c1f9-98a3-4bd7-ab22-4fd41d66d56d",
"id": "c18df781-3005-4933-b724-d97ce7b20e5d",
"name": "=",
"displayName": "=",
"linkageId": "9dc84729-12fd-4f31-a686-99abc5dd123b",
}
var v2 = {
"id": "4dd64046-b51a-4b4f-9a07-ca9219aeaa97",
"cardId": "a842c1f9-98a3-4bd7-ab22-4fd41d66d56d",
"id": "c18df781-3005-4933-b724-d97ce7b20e5d",
"name": "=",
"displayName": "=",
"linkageId": "9dc84729-12fd-4f31-a686-99abc5dd123b",
}
JSON.stringify(v1) === JSON.stringify(v2)
objectHash(v1) === objectHash(v2)
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
JSON.stringify | |
object-hash |
Test name | Executions per second |
---|---|
JSON.stringify | 1944260.0 Ops/sec |
object-hash | 14512.2 Ops/sec |
Benchmark Overview
MeasureThat.net is a website that allows users to create and run JavaScript microbenchmarks. The provided benchmark definition consists of two test cases: JSON.stringify
and object-hash
. These tests compare the performance of two approaches for hashing objects.
Test Case 1: JSON.stringify
JSON.stringify(v1)
and JSON.stringify(v2)
, where v1
and v2
are two identical objects.JSON.stringify()
in hashing objects. JSON.stringify()
converts a JavaScript object into a JSON string, which can be hashed using various algorithms.Test Case 2: object-hash
objectHash(v1)
and objectHash(v2)
, where v1
and v2
are two identical objects.objectHash()
in hashing objects. objectHash()
is a custom implementation specifically designed for hashing JavaScript objects.JSON.stringify()
.Library: Hash-sum
The provided benchmark uses two libraries:
JSON.stringify()
to compare its performance.Special JS Feature/Syntax
There are no specific special features or syntaxes mentioned in the benchmark definition. However, it's worth noting that the use of JSON serialization and hashing implies familiarity with the standard JavaScript object notation and data structures.
Alternatives
Some alternative approaches to hashing objects include:
In summary, the benchmark definition provides a clear understanding of the test cases and their purposes, as well as the libraries used. By considering the pros and cons of each approach, developers can make informed decisions about which hashing method to use in their own projects.