コンテンツにスキップ

ベンチマーク

プロジェクトには目的の異なる 2 つの独立したベンチマークセットアップがあります:

継続的ベンチマーク:ソースと結果は https://github.com/ringsaturn/tz-benchmark、可視化は https://ringsaturn.github.io/tz-benchmark/ で確認できます。各リリース時に GitHub Actions で自動実行され、パッケージ間の比較を行います。 GitHub Actions ランナーは開発マシンとハードウェアが異なるため、絶対値はローカル実行と異なりますが、パッケージ間の相対的な傾向が重要です。

ローカルベンチマーク:以下の表は Apple M3 Max 搭載 MacBook Pro で測定されました。これらは最新ハードウェアにおける実際のレイテンシをより代表するものです。

方法論

各ファインダーは一度初期化され、すべてのクエリで再利用されます。これは推奨される本番環境パターンです。クエリは世界都市座標の代表サンプルと意図的な境界エッジケースポイントを使用します。

Go (tzf v1.2.0)

TargetDatasetScenarioMedian (ns)p99 (ns)Approx throughput (ops/s)Memory (MiB)
DefaultFindertopology-simplified + preindexedge case · GetTimezoneName500.01250.01694.9K74.90
FuzzyFinderpreindexedge case · GetTimezoneName250.0375.03521.1K2.40
Findertopology-simplifiededge case · GetTimezoneName250.0875.03022.1K72.70
FullFinderfull-precision + preindexedge case · GetTimezoneName542.01375.01586.3K422.90
Finderfull-precisionedge case · GetTimezoneName292.01167.02678.1K420.70
DefaultFindertopology-simplified + preindexrandom world cities · GetTimezoneName167.0791.03855.1K74.90
FuzzyFinderpreindexrandom world cities · GetTimezoneName167.0333.04608.3K2.40
Findertopology-simplifiedrandom world cities · GetTimezoneName209.01250.03076.0K72.70
FullFinderfull-precision + preindexrandom world cities · GetTimezoneName208.0917.03527.3K422.90
Finderfull-precisionrandom world cities · GetTimezoneName250.01167.02953.3K420.70
Findertopology-simplified + GridIndexrandom world cities · GetTimezoneName209.01167.03202.0K72.70
Findertopology-simplified (no GridIndex)random world cities · GetTimezoneName1833.02875.0612.4K67.00
DefaultFindertopology-simplified + preindexrandom world cities · GetTimezoneNames416.01375.01956.9K74.90
FuzzyFinderpreindexrandom world cities · GetTimezoneNames208.0334.04347.8K2.40
Findertopology-simplifiedrandom world cities · GetTimezoneNames417.01375.01931.2K72.70
FullFinderfull-precision + preindexrandom world cities · GetTimezoneNames459.01750.01623.1K422.90

Rust (tzf-rs v1.3.3)

Topology-Simplified (bundled) / Random Cities:

TargetDatasetScenarioMedian estimate (µs)Approx throughput (ops/s)Avg peak RSS (MiB)
Findertopology-simplifiedYStripes only0.64571,548,635112.30
Findertopology-simplifiedNo index4.3948227,54259.92
DefaultFindertopology-simplified + preindexYStripes only0.38002,631,787134.48
DefaultFindertopology-simplified + preindexNo index4.4922222,60885.66

Topology-Simplified (bundled) / Edge Cities (FuzzyFinder misses)

TargetDatasetScenarioMedian estimate (µs)Approx throughput (ops/s)
FuzzyFinderpreindexFuzzyFinder miss0.22004,546,074
DefaultFinder (YStripes)topology-simplified + preindexDefaultFinder (YStripes) fallback0.74561,341,184
Findertopology-simplifiedYStripes0.49752,010,131
Findertopology-simplifiedNo index4.3948227,542
DefaultFindertopology-simplified + preindexYStripes0.71541,397,858
DefaultFindertopology-simplified + preindexNo index4.4922222,608

Full-Precision (full):

TargetDatasetScenarioMedian estimate (µs)Approx throughput (ops/s)Avg peak RSS (MiB)
Finder (full)full-precisionYStripes only1.7158582,819568.78
Finder (full)full-precisionNo index38.937025,683260.95
DefaultFinder (full)full-precision + preindexYStripes only0.49842,006,421592.25
DefaultFinder (full)full-precision + preindexNo index6.6012151,488287.32

Python (tzfpy v1.2.0)

tzfpy は tzf-rs の PyO3 バインディングです。ベンチマークは pytest-benchmark を使用し、単一の get_tz() 呼び出し(ランダム座標、トポロジー簡略化データセット)を測定します。 Apple M3 Max 搭載 MacBook Pro での結果です。

インデックスモード中央値 (µs)平均 (µs)スループット (Kops/s)メモリ
デフォルト(YStripes 有効)1.79341.8321545.8~120 MB
YStripes なし(_TZFPY_DISABLE_Y_STRIPES=12.52132.5338394.7未測定

呼び出しあたりのオーバーヘッドは生の Rust の数値と同程度です。tzf-rs の数値との差は PyO3 経由の Python → Rust FFI コストを反映しています。

主な観察結果

  • YStripes インデックスは完全精度 Finder に大きな改善をもたらします:37.7 µs(インデックスなし)から 2.1 µs へ、約 18 倍の高速化です。トポロジー簡略化データセットでは効果は小さいものの、依然として顕著です(6.5 µs → 1.2 µs、約 5 倍)。
  • DefaultFinder(プレインデックス + ポリゴン)は一般的なワークロードで一貫して最良です:データセットに関係なく、中央値約 1 µs、メモリ約 75 から 126 MB。
  • FuzzyFinder(プレインデックスのみ)は約 470 ns で最速ですが、単一のタイムゾーンポリゴン内に完全に収まるタイルのみをカバーします。境界付近や未カバータイルのポイントでは、推測せずに結果なしを返します。ワークロードがタイムゾーン境界から十分離れていることが分かっている場合にのみ単独で使用してください。
  • Python (tzfpy) は Rust ベースラインに加えて約 0.5 から 1 µs の PyO3 FFI オーバーヘッドがあります。YStripes 有効時の中央値は約 1.8 µs で、ほとんどのバックエンド API の予算内に収まります。
  • メモリはデータセットに比例します:Rust でトポロジー簡略化から完全精度に切り替えると、YStripes 有効時で約 450 MB 増加します。
最終更新日