{
  "schemaVersion": 1,
  "slug": "cbor-x-vs-json-serialization-benchmark",
  "tool": {
    "name": "cbor-x",
    "repo": "kriszyp/cbor-x",
    "version": "1.6.9"
  },
  "environment": {
    "arch": "aarch64",
    "cpu": "Neoverse-N1 x2, CPUQuota 150%",
    "memMB": 2048,
    "os": "Ubuntu 24.04.4 LTS",
    "runtime": "Node.js 24.21.0",
    "installSeconds": 1.8,
    "installBytes": 2461929
  },
  "method": {
    "hypothesis": "README 주장: Node.js 환경에서 다른 자바스크립트 CBOR 구현체보다 처리 속도가 최대 10배 빠르고 내장 JSON.stringify 및 JSON.parse보다도 전반적으로 빠르다고 설명한다. 이 환경에서 확인: 네이티브 애드온 빌드 없이 순수 자바스크립트로 동작하는 샌드박스에서 구조화된 객체 배열을 직렬화·역직렬화할 때 cbor-x가 내장 JSON 대비 더 짧은 소요 시간과 더 작은 출력 크기를 기록하는지 확인한다.",
    "conditions": [
      "설치 스크립트가 비활성화된 샌드박스 조건이므로 선택적 네이티브 애드온 없이 순수 자바스크립트 실행 경로로 동작하며 내장 JSON 직렬화와 비교",
      "문자열과 숫자 및 불리언과 배열을 포함한 키 8개 구조의 객체 레코드 1000건 배열을 결정적으로 생성",
      "측정 전 워밍업을 거친 뒤 동일한 입력 데이터를 여러 번 반복 인코딩 및 디코딩하여 합산 소요 시간과 직렬화 결과 바이트 크기를 기록",
      "전체 직렬화 및 역직렬화 속도 비율인 totalSpeedup이 1보다 크면 같은 방향이고 1 이하이면 다른 방향으로 판정"
    ],
    "repeats": 7
  },
  "script": "import { encode, decode } from 'cbor-x';\nimport { performance } from 'node:perf_hooks';\n\nconst dataset = Array.from({ length: 1000 }, (_, i) => ({\n  id: i + 1,\n  name: `user_record_${i}`,\n  active: i % 2 === 0,\n  score: (i * 17 + 3) / 10,\n  category: i % 3 === 0 ? 'alpha' : i % 3 === 1 ? 'beta' : 'gamma',\n  tags: [`tag_${i % 5}`, `group_${i % 7}`, 'standard'],\n  createdAt: 1700000000000 + i * 60000,\n  meta: { retries: i % 4, verified: i % 5 !== 0, region: 'ap-northeast' }\n}));\n\nfor (let w = 0; w < 5; w++) {\n  const b = encode(dataset);\n  const d1 = decode(b);\n  const s = JSON.stringify(dataset);\n  const d2 = JSON.parse(s);\n  if (d1.length !== d2.length) throw new Error('Mismatch');\n}\n\nconst iterations = 200;\n\nconst cborBytes = encode(dataset).byteLength;\nconst jsonBytes = Buffer.byteLength(JSON.stringify(dataset), 'utf8');\n\nconst t0 = performance.now();\nlet lastCbor;\nfor (let i = 0; i < iterations; i++) {\n  lastCbor = encode(dataset);\n}\nconst cborEncodeMs = performance.now() - t0;\n\nconst t1 = performance.now();\nlet lastDecodedCbor;\nfor (let i = 0; i < iterations; i++) {\n  lastDecodedCbor = decode(lastCbor);\n}\nconst cborDecodeMs = performance.now() - t1;\n\nconst t2 = performance.now();\nlet lastJson;\nfor (let i = 0; i < iterations; i++) {\n  lastJson = JSON.stringify(dataset);\n}\nconst jsonEncodeMs = performance.now() - t2;\n\nconst t3 = performance.now();\nlet lastDecodedJson;\nfor (let i = 0; i < iterations; i++) {\n  lastDecodedJson = JSON.parse(lastJson);\n}\nconst jsonDecodeMs = performance.now() - t3;\n\nif (lastDecodedCbor.length !== 1000 || lastDecodedJson.length !== 1000) {\n  throw new Error('Validation failed');\n}\n\nconst cborTotalMs = cborEncodeMs + cborDecodeMs;\nconst jsonTotalMs = jsonEncodeMs + jsonDecodeMs;\n\nconst round = (n) => Number(n.toFixed(3));\n\nconsole.log(JSON.stringify({\n  cborEncodeMs: round(cborEncodeMs),\n  jsonEncodeMs: round(jsonEncodeMs),\n  cborDecodeMs: round(cborDecodeMs),\n  jsonDecodeMs: round(jsonDecodeMs),\n  cborTotalMs: round(cborTotalMs),\n  jsonTotalMs: round(jsonTotalMs),\n  cborBytes,\n  jsonBytes\n}));",
  "scriptSha256": "dadb321d23ef9d6df4879ee94296bdb8a33a7723c0c6463730b516907f955955",
  "runs": [
    {
      "run": 1,
      "cborEncodeMs": 257.185,
      "jsonEncodeMs": 183.624,
      "cborDecodeMs": 378.178,
      "jsonDecodeMs": 262.814,
      "cborTotalMs": 635.363,
      "jsonTotalMs": 446.437,
      "cborBytes": 161665,
      "jsonBytes": 208297,
      "wallMs": 1319.252
    },
    {
      "run": 2,
      "cborEncodeMs": 258.547,
      "jsonEncodeMs": 178.332,
      "cborDecodeMs": 362.638,
      "jsonDecodeMs": 265.121,
      "cborTotalMs": 621.186,
      "jsonTotalMs": 443.453,
      "cborBytes": 161665,
      "jsonBytes": 208297,
      "wallMs": 1318.024
    },
    {
      "run": 3,
      "cborEncodeMs": 261.359,
      "jsonEncodeMs": 183.736,
      "cborDecodeMs": 359.644,
      "jsonDecodeMs": 261.82,
      "cborTotalMs": 621.003,
      "jsonTotalMs": 445.555,
      "cborBytes": 161665,
      "jsonBytes": 208297,
      "wallMs": 1267.426
    },
    {
      "run": 4,
      "cborEncodeMs": 256.764,
      "jsonEncodeMs": 180.659,
      "cborDecodeMs": 366.112,
      "jsonDecodeMs": 270.6,
      "cborTotalMs": 622.876,
      "jsonTotalMs": 451.259,
      "cborBytes": 161665,
      "jsonBytes": 208297,
      "wallMs": 1319.748
    },
    {
      "run": 5,
      "cborEncodeMs": 256.643,
      "jsonEncodeMs": 186.418,
      "cborDecodeMs": 359.255,
      "jsonDecodeMs": 244.709,
      "cborTotalMs": 615.897,
      "jsonTotalMs": 431.128,
      "cborBytes": 161665,
      "jsonBytes": 208297,
      "wallMs": 1318.258
    },
    {
      "run": 6,
      "cborEncodeMs": 266.528,
      "jsonEncodeMs": 179.723,
      "cborDecodeMs": 359.92,
      "jsonDecodeMs": 261.055,
      "cborTotalMs": 626.448,
      "jsonTotalMs": 440.777,
      "cborBytes": 161665,
      "jsonBytes": 208297,
      "wallMs": 1319.598
    },
    {
      "run": 7,
      "cborEncodeMs": 261.804,
      "jsonEncodeMs": 185.325,
      "cborDecodeMs": 361.825,
      "jsonDecodeMs": 261.275,
      "cborTotalMs": 623.628,
      "jsonTotalMs": 446.6,
      "cborBytes": 161665,
      "jsonBytes": 208297,
      "wallMs": 1267.251
    }
  ],
  "summary": {
    "cborEncodeMs": {
      "median": 258.547,
      "min": 256.643,
      "max": 266.528,
      "unit": "ms"
    },
    "jsonEncodeMs": {
      "median": 183.624,
      "min": 178.332,
      "max": 186.418,
      "unit": "ms"
    },
    "cborDecodeMs": {
      "median": 361.825,
      "min": 359.255,
      "max": 378.178,
      "unit": "ms"
    },
    "jsonDecodeMs": {
      "median": 261.82,
      "min": 244.709,
      "max": 270.6,
      "unit": "ms"
    },
    "cborTotalMs": {
      "median": 622.876,
      "min": 615.897,
      "max": 635.363,
      "unit": "ms"
    },
    "jsonTotalMs": {
      "median": 445.555,
      "min": 431.128,
      "max": 451.259,
      "unit": "ms"
    },
    "cborBytes": {
      "median": 161665,
      "min": 161665,
      "max": 161665,
      "unit": "B"
    },
    "jsonBytes": {
      "median": 208297,
      "min": 208297,
      "max": 208297,
      "unit": "B"
    },
    "encodeSpeedup": 0.710215,
    "decodeSpeedup": 0.723609,
    "totalSpeedup": 0.715319,
    "sizeChangePct": -22.387264
  },
  "chart": {
    "title": {
      "ko": "직렬화·역직렬화 소요 시간과 출력 크기",
      "en": "Serialization and deserialization time and output size"
    },
    "series": [
      {
        "id": "cbor-x",
        "role": "target",
        "label": {
          "ko": "cbor-x",
          "en": "cbor-x"
        },
        "short": {
          "ko": "CBOR-X",
          "en": "CBOR-X"
        }
      },
      {
        "id": "json",
        "role": "baseline",
        "label": {
          "ko": "JSON 내장 함수",
          "en": "Built-in JSON"
        },
        "short": {
          "ko": "JSON",
          "en": "JSON"
        }
      }
    ],
    "panels": [
      {
        "title": {
          "ko": "인코딩 소요 시간",
          "en": "Encoding time"
        },
        "unit": "ms",
        "kind": "time",
        "better": "lower",
        "keys": {
          "cbor-x": "cborEncodeMs",
          "json": "jsonEncodeMs"
        }
      },
      {
        "title": {
          "ko": "디코딩 소요 시간",
          "en": "Decoding time"
        },
        "unit": "ms",
        "kind": "time",
        "better": "lower",
        "keys": {
          "cbor-x": "cborDecodeMs",
          "json": "jsonDecodeMs"
        }
      },
      {
        "title": {
          "ko": "직렬화 출력 크기",
          "en": "Serialized output size"
        },
        "unit": "B",
        "kind": "size",
        "better": "lower",
        "keys": {
          "cbor-x": "cborBytes",
          "json": "jsonBytes"
        }
      }
    ]
  },
  "createdAt": "2026-11-17T01:13:49Z",
  "claim": {
    "quote": "Currently, it is over 3-10x faster than any other CBOR JS implementation (including cbor-js and cborg) and faster than most MessagePack encoders, Avro, and generally faster than native V8 JSON.stringify/parse, on NodeJS.",
    "url": "https://github.com/kriszyp/cbor-x#readme",
    "numbers": [
      10
    ]
  }
}
