{
  "schemaVersion": 1,
  "slug": "charset-normalizer-vs-chardet-encoding-detection",
  "tool": {
    "name": "charset-normalizer",
    "repo": "jawah/charset_normalizer",
    "version": "3.5.2"
  },
  "environment": {
    "arch": "aarch64",
    "cpu": "Neoverse-N1 x2, CPUQuota 150%",
    "memMB": 2048,
    "os": "Ubuntu 24.04.5 LTS",
    "runtime": "Python 3.12.3",
    "installSeconds": 5.5,
    "installBytes": 21862778
  },
  "method": {
    "hypothesis": "README 주장: 대용량 텍스트에서 chardet의 기본 최대 바이트 제한을 풀고 비교할 때 charset-normalizer의 인코딩 탐지 속도가 chardet보다 10배 빠르다고 설명한다. 이 환경에서 확인: 결정적으로 생성한 대용량 다국어 바이트 데이터를 대상으로 charset-normalizer와 chardet의 전체 버퍼 인코딩 탐지 소요 시간을 측정했을 때 charset-normalizer가 더 짧은 시간에 탐지를 마치는지 확인한다.",
    "conditions": [
      "원문의 외부 대용량 파일 및 별도 바이트 제한 해제 설정 대신 메모리에서 결정적으로 생성한 다국어 텍스트 줄 5000개 분량의 단일 바이트 버퍼를 기본 탐지 함수로 비교",
      "아스키 문자와 한글 및 유럽어 문자를 섞은 문장 줄 5000개를 이어 붙여 300kb 크기의 바이트 데이터를 구성",
      "측정 전 워밍업을 먼저 수행한 뒤 동일한 바이트 버퍼를 여러 번 반복 탐지하여 합산 소요 시간을 측정",
      "speedup 이 1보다 크면 같은 방향, 1 이하이면 다른 방향"
    ],
    "repeats": 7
  },
  "script": "import json\nimport time\nimport chardet\nfrom charset_normalizer import from_bytes\n\nline = \"Log entry: status=OK, message=데이터 처리 완료 café\\n\".encode(\"utf-8\")\npayload = line * 5000\niterations = 5\n\n_ = from_bytes(payload).best()\n_ = chardet.detect(payload)\n\nt0 = time.perf_counter()\nfor _ in range(iterations):\n    res_cn = from_bytes(payload).best()\n    if res_cn is None:\n        raise RuntimeError(\"detection failed\")\ncn_ms = (time.perf_counter() - t0) * 1000.0\n\nt1 = time.perf_counter()\nfor _ in range(iterations):\n    res_cd = chardet.detect(payload)\n    if not res_cd or not res_cd.get(\"encoding\"):\n        raise RuntimeError(\"detection failed\")\ncd_ms = (time.perf_counter() - t1) * 1000.0\n\nprint(json.dumps({\"charsetNormalizerMs\": round(cn_ms, 3), \"chardetMs\": round(cd_ms, 3)}))\n",
  "scriptSha256": "daab14e7d0714a98aef3b0bcf8aee3614a9ee90c5f662657bea5fecfddd6d183",
  "runs": [
    {
      "run": 1,
      "charsetNormalizerMs": 3.013,
      "chardetMs": 5.348,
      "wallMs": 318.215
    },
    {
      "run": 2,
      "charsetNormalizerMs": 3.102,
      "chardetMs": 5.073,
      "wallMs": 265.799
    },
    {
      "run": 3,
      "charsetNormalizerMs": 2.948,
      "chardetMs": 5.174,
      "wallMs": 265.283
    },
    {
      "run": 4,
      "charsetNormalizerMs": 3.556,
      "chardetMs": 5.11,
      "wallMs": 266.057
    },
    {
      "run": 5,
      "charsetNormalizerMs": 3.022,
      "chardetMs": 5.094,
      "wallMs": 266.902
    },
    {
      "run": 6,
      "charsetNormalizerMs": 3.026,
      "chardetMs": 5.321,
      "wallMs": 266.32
    },
    {
      "run": 7,
      "charsetNormalizerMs": 3.053,
      "chardetMs": 5.514,
      "wallMs": 265.678
    }
  ],
  "summary": {
    "charsetNormalizerMs": {
      "median": 3.026,
      "min": 2.948,
      "max": 3.556,
      "unit": "ms"
    },
    "chardetMs": {
      "median": 5.174,
      "min": 5.073,
      "max": 5.514,
      "unit": "ms"
    },
    "speedup": 1.709848
  },
  "chart": {
    "title": {
      "ko": "인코딩 탐지 소요 시간 비교",
      "en": "Encoding detection time comparison"
    },
    "series": [
      {
        "id": "charset-normalizer",
        "role": "target",
        "label": {
          "ko": "charset-normalizer",
          "en": "charset-normalizer"
        },
        "short": {
          "ko": "normalizer",
          "en": "normalizer"
        }
      },
      {
        "id": "chardet",
        "role": "baseline",
        "label": {
          "ko": "chardet",
          "en": "chardet"
        },
        "short": {
          "ko": "chardet",
          "en": "chardet"
        }
      }
    ],
    "panels": [
      {
        "title": {
          "ko": "탐지 소요 시간",
          "en": "Detection time"
        },
        "unit": "ms",
        "kind": "time",
        "better": "lower",
        "keys": {
          "charset-normalizer": "charsetNormalizerMs",
          "chardet": "chardetMs"
        }
      }
    ]
  },
  "createdAt": "2026-11-18T01:22:41Z",
  "claim": {
    "quote": "Expect 10X faster with large contents when you uncap Chardet max_bytes default assumption.",
    "url": "https://github.com/jawah/charset_normalizer#readme",
    "numbers": [
      10
    ]
  }
}
