[clang] [clang-tools-extra] [lldb] [llvm] [Support][JSON] Use `std::unordered_map` for object storage (PR #171230)
Cyndy Ishida via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 16 07:48:36 PDT 2026
================
@@ -0,0 +1,288 @@
+//===- JSONParserBM.cpp - JSON parser benchmarks --------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "benchmark/benchmark.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/JSON.h"
+#include <algorithm>
+#include <atomic>
+#include <random>
+
+using namespace llvm;
+
+//===----------------------------------------------------------------------===//
+// Memory tracking via global operator new
+//===----------------------------------------------------------------------===//
+
+static std::atomic_size_t TotalAllocatedBytes{0};
+static std::atomic_size_t NumAllocs{0};
+static bool TrackMemory = false;
+
+// Single-object new/delete.
+void *operator new(std::size_t Size) {
----------------
cyndyishida wrote:
Can you use `benchmark::RegisterMemoryManager` instead?
https://github.com/llvm/llvm-project/pull/171230
More information about the cfe-commits
mailing list