[llvm-commits] [compiler-rt] r172209 - /compiler-rt/trunk/lib/sanitizer_common/tests/standalone_malloc_test.cc
Dmitry Vyukov
dvyukov at google.com
Fri Jan 11 07:57:20 PST 2013
Author: dvyukov
Date: Fri Jan 11 09:57:19 2013
New Revision: 172209
URL: http://llvm.org/viewvc/llvm-project?rev=172209&view=rev
Log:
asan: improve the benchmark
Modified:
compiler-rt/trunk/lib/sanitizer_common/tests/standalone_malloc_test.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/standalone_malloc_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/standalone_malloc_test.cc?rev=172209&r1=172208&r2=172209&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/standalone_malloc_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/standalone_malloc_test.cc Fri Jan 11 09:57:19 2013
@@ -7,8 +7,7 @@
using namespace std;
const size_t kNumThreds = 16;
-const size_t kNumIters = 1 << 20;
-
+const size_t kNumIters = 1 << 23;
static void *MallocThread(void *t) {
size_t total_malloced = 0, total_freed = 0;
@@ -17,9 +16,12 @@
vector<pair<char *, size_t> > allocated;
allocated.reserve(kNumIters);
for (size_t i = 1; i < kNumIters; i++) {
- if ((i % (kNumIters / 2)) == 0 && tid == 0)
+ if ((i % (kNumIters / 4)) == 0 && tid == 0)
fprintf(stderr, " T[%ld] iter %ld\n", tid, i);
- if ((i % 5) <= 2) { // 0, 1, 2
+ bool allocate = (i % 5) <= 2; // 60% malloc, 40% free
+ if (i > kNumIters / 4)
+ allocate = i % 2; // then switch to 50% malloc, 50% free
+ if (allocate) {
size_t size = 1 + (i % 200);
if ((i % 10001) == 0)
size *= 4096;
@@ -28,7 +30,7 @@
x[0] = x[size - 1] = x[size / 2] = 0;
allocated.push_back(make_pair(x, size));
max_in_use = max(max_in_use, total_malloced - total_freed);
- } else { // 3, 4
+ } else {
if (allocated.empty()) continue;
size_t slot = i % allocated.size();
char *p = allocated[slot].first;
More information about the llvm-commits
mailing list