deep-equal-benchmark.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. "use strict";
  2. var Benchmark = require("benchmark");
  3. var deepEqual = require("./deep-equal");
  4. var suite = new Benchmark.Suite();
  5. var complex1 = {
  6. "1e116061-59bf-433a-8ab0-017b67a51d26":
  7. "a7fd22ab-e809-414f-ad55-9c97598395d8",
  8. "3824e8b7-22f5-489c-9919-43b432e3af6b":
  9. "548baefd-f43c-4dc9-9df5-f7c9c96223b0",
  10. "123e5750-eb66-45e5-a770-310879203b33":
  11. "89ff817d-65a2-4598-b190-21c128096e6a",
  12. "1d66be95-8aaa-4167-9a47-e7ee19bb0735":
  13. "64349492-56e8-4100-9552-a89fb4a9aef4",
  14. "f5538565-dc92-4ee4-a762-1ba5fe0528f6": {
  15. "53631f78-2f2a-448f-89c7-ed3585e8e6f0":
  16. "2cce00ee-f5ee-43ef-878f-958597b23225",
  17. "73e8298b-72fd-4969-afc1-d891b61e744f":
  18. "4e57aa30-af51-4d78-887c-019755e5d117",
  19. "85439907-5b0e-4a08-8cfa-902a68dc3cc0":
  20. "9639add9-6897-4cf0-b3d3-2ebf9c214f01",
  21. "d4ae9d87-bd6c-47e0-95a1-6f4eb4211549":
  22. "41fd3dd2-43ce-47f2-b92e-462474d07a6f",
  23. "f70345a2-0ea3-45a6-bafa-8c7a72379277": {
  24. "1bce714b-cd0a-417d-9a0c-bf4b7d35c0c4":
  25. "3b8b0dde-e2ed-4b34-ac8d-729ba3c9667e",
  26. "13e05c60-97d1-43f0-a6ef-d5247f4dd11f":
  27. "60f685a4-6558-4ade-9d4b-28281c3989db",
  28. "925b2609-e7b7-42f5-82cf-2d995697cec5":
  29. "79115261-8161-4a6c-9487-47847276a717",
  30. "52d644ac-7b33-4b79-b5b3-5afe7fd4ec2c": [
  31. "3c2ae716-92f1-4a3d-b98f-50ea49f51c45",
  32. "de76b822-71b3-4b5a-a041-4140378b70e2",
  33. "0302a405-1d58-44fa-a0c6-dd07bb0ca26e",
  34. new Date(),
  35. new Error(),
  36. new RegExp(),
  37. // eslint-disable-next-line no-undef
  38. new Map(),
  39. new Set(),
  40. // eslint-disable-next-line no-undef, ie11/no-weak-collections
  41. new WeakMap(),
  42. // eslint-disable-next-line no-undef, ie11/no-weak-collections
  43. new WeakSet()
  44. ]
  45. }
  46. }
  47. };
  48. var complex2 = Object.create(complex1);
  49. var cyclic1 = {
  50. "4a092cd1-225e-4739-8331-d6564aafb702":
  51. "d0cebbe0-23fb-4cc4-8fa0-ef11ceedf12e"
  52. };
  53. cyclic1.cyclicRef = cyclic1;
  54. var cyclic2 = Object.create(cyclic1);
  55. // add tests
  56. suite
  57. .add("complex objects", function() {
  58. return deepEqual(complex1, complex2);
  59. })
  60. .add("cyclic references", function() {
  61. return deepEqual(cyclic1, cyclic2);
  62. })
  63. // add listeners
  64. .on("cycle", function(event) {
  65. // eslint-disable-next-line no-console
  66. console.log(String(event.target));
  67. })
  68. // run async
  69. .run({ async: true });