{
  "schemaVersion": 1,
  "slug": "handlebars-vs-mustache-template-rendering",
  "tool": {
    "name": "Handlebars.js",
    "repo": "handlebars-lang/handlebars.js",
    "version": "4.7.10"
  },
  "environment": {
    "arch": "aarch64",
    "cpu": "Neoverse-N1 x2, CPUQuota 150%",
    "memMB": 2048,
    "os": "Ubuntu 24.04.5 LTS",
    "runtime": "Node.js 24.21.0",
    "installSeconds": 2.4,
    "installBytes": 5572808
  },
  "method": {
    "hypothesis": "README 주장: 새로 작성된 Handlebars는 동등한 Mustache 템플릿과 비교해 여러 성능 테스트에서 렌더링 속도가 다섯 배에서 최대 7배 빠르다. 이 환경에서 확인: Node.js 샌드박스에서 동일한 중첩 배열 템플릿과 레코드 1000건을 사전 컴파일하여 반복 렌더링할 때 Handlebars의 실행 시간(handlebarsMs)이 Mustache(mustacheMs)보다 짧아 speedup이 1보다 큰지 확인한다.",
    "conditions": [
      "원문 벤치마크 스위트 대신 단일 Node.js 컨테이너 환경에서 문자열 치환과 배열 순회가 포함된 고정 HTML 템플릿 1개와 입력 데이터셋으로 측정",
      "각 데이터는 이름과 지역 문자열 및 하위 배열 항목 5개를 포함한 레코드 1000건으로 구성",
      "두 라이브러리 모두 템플릿을 사전 컴파일 및 사전 파싱한 뒤 워밍업을 거쳐 동일한 레코드 1000건 배열을 여러 번 반복 렌더링한 소요 시간을 측정",
      "mustacheMs를 handlebarsMs로 나눈 speedup이 1보다 크면 같은 방향, 1 이하이면 다른 방향, 실행 오류나 출력 불일치 시 비교 불가로 판정"
    ],
    "repeats": 5
  },
  "script": "import { performance } from 'node:perf_hooks';\nimport Handlebars from 'handlebars';\nimport Mustache from 'mustache';\n\nconst source = '<p>Hello, my name is {{name}}. I am from {{hometown}}.</p><ul>{{#kids}}<li>{{name}} is {{age}}</li>{{/kids}}</ul>';\n\nconst records = Array.from({ length: 1000 }, (_, i) => ({\n  name: `User_${i}`,\n  hometown: `City_${i % 50}, ST`,\n  kids: Array.from({ length: 5 }, (__, k) => ({\n    name: `Kid_${i}_${k}`,\n    age: String((i + k) % 18 + 1)\n  }))\n}));\n\nconst hbTemplate = Handlebars.compile(source);\nMustache.parse(source);\n\nif (hbTemplate(records[0]) !== Mustache.render(source, records[0])) {\n  throw new Error('Rendered output mismatch between Handlebars and Mustache');\n}\n\nfor (let w = 0; w < 5; w++) {\n  for (let i = 0; i < records.length; i++) {\n    hbTemplate(records[i]);\n    Mustache.render(source, records[i]);\n  }\n}\n\nconst iterations = 50;\nlet hbSink = 0;\nconst t0 = performance.now();\nfor (let r = 0; r < iterations; r++) {\n  for (let i = 0; i < records.length; i++) {\n    hbSink += hbTemplate(records[i]).length;\n  }\n}\nconst handlebarsMs = performance.now() - t0;\n\nlet muSink = 0;\nconst t1 = performance.now();\nfor (let r = 0; r < iterations; r++) {\n  for (let i = 0; i < records.length; i++) {\n    muSink += Mustache.render(source, records[i]).length;\n  }\n}\nconst mustacheMs = performance.now() - t1;\n\nif (hbSink !== muSink) {\n  throw new Error('Total output length mismatch');\n}\n\nconsole.log(JSON.stringify({\n  handlebarsMs: Number(handlebarsMs.toFixed(3)),\n  mustacheMs: Number(mustacheMs.toFixed(3))\n}));",
  "scriptSha256": "76958552555c61c561873f8bf17786b1be3d61c33e5a09b05fdb0b53b962502d",
  "runs": [
    {
      "run": 1,
      "handlebarsMs": 181.526,
      "mustacheMs": 215.968,
      "wallMs": 665.84
    },
    {
      "run": 2,
      "handlebarsMs": 186.439,
      "mustacheMs": 213.909,
      "wallMs": 666.761
    },
    {
      "run": 3,
      "handlebarsMs": 198.143,
      "mustacheMs": 221.209,
      "wallMs": 717.351
    },
    {
      "run": 4,
      "handlebarsMs": 188.125,
      "mustacheMs": 222.184,
      "wallMs": 666.762
    },
    {
      "run": 5,
      "handlebarsMs": 176.554,
      "mustacheMs": 218.537,
      "wallMs": 667.901
    }
  ],
  "summary": {
    "handlebarsMs": {
      "median": 186.439,
      "min": 176.554,
      "max": 198.143,
      "unit": "ms"
    },
    "mustacheMs": {
      "median": 218.537,
      "min": 213.909,
      "max": 222.184,
      "unit": "ms"
    },
    "speedup": 1.172164
  },
  "chart": {
    "title": {
      "ko": "템플릿 렌더링 소요 시간 비교",
      "en": "Template rendering time comparison"
    },
    "series": [
      {
        "id": "handlebars",
        "role": "target",
        "label": {
          "ko": "Handlebars.compile",
          "en": "Handlebars.compile"
        },
        "short": {
          "ko": "Handlebars",
          "en": "Handlebars"
        }
      },
      {
        "id": "mustache",
        "role": "baseline",
        "label": {
          "ko": "Mustache.render",
          "en": "Mustache.render"
        },
        "short": {
          "ko": "Mustache",
          "en": "Mustache"
        }
      }
    ],
    "panels": [
      {
        "title": {
          "ko": "반복 렌더링 소요 시간",
          "en": "Repeated rendering time"
        },
        "unit": "ms",
        "kind": "time",
        "better": "lower",
        "keys": {
          "handlebars": "handlebarsMs",
          "mustache": "mustacheMs"
        }
      }
    ]
  },
  "createdAt": "2026-11-21T06:01:49Z",
  "claim": {
    "quote": "The rewritten Handlebars (current version) is faster than the old version, with many performance tests being 5 to 7 times faster than the Mustache equivalent.",
    "url": "https://github.com/handlebars-lang/handlebars.js#readme",
    "numbers": [
      7
    ]
  }
}
