aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornjn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9>2005-12-17 00:22:39 +0000
committernjn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9>2005-12-17 00:22:39 +0000
commit444e4b4b2884c3af83e7479775b57a8963a17788 (patch)
tree5d678dfdcb5788cf16b0cfe968817f761713d098
parenta527a4998aa88e72f0108deefb2cf4cb182a86b3 (diff)
downloadvalgrind-444e4b4b2884c3af83e7479775b57a8963a17788.tar.gz
Add a malloc/free stress test.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5362 a5019735-40e9-0310-863c-91ae7b9d1cf9
-rw-r--r--perf/Makefile.am3
-rw-r--r--perf/README9
-rw-r--r--perf/heap.c39
-rw-r--r--perf/heap.vgperf2
-rw-r--r--perf/vg_perf.in4
5 files changed, 54 insertions, 3 deletions
diff --git a/perf/Makefile.am b/perf/Makefile.am
index d6898bfc6..cd31e5f0b 100644
--- a/perf/Makefile.am
+++ b/perf/Makefile.am
@@ -6,10 +6,11 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
bz2.vgperf \
fbench.vgperf \
ffbench.vgperf \
+ heap.vgperf \
sarp.vgperf
check_PROGRAMS = \
- bigcode bz2 fbench ffbench sarp
+ bigcode bz2 fbench ffbench heap sarp
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g -O
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_builddir)/include
diff --git a/perf/README b/perf/README
index 951927946..0dd8c16cc 100644
--- a/perf/README
+++ b/perf/README
@@ -13,6 +13,15 @@ bigcode1, bigcode2:
of runtime, particularly on larger programs.
- Weaknesses: Highly artificial.
+heap:
+- Description: Does a lot of heap allocation and deallocation, and has a lot
+ of heap blocks live while doing so.
+- Strengths: Stress test for an important sub-system; bug #105039 showed
+ that inefficiencies in heap allocation can make a big
+ difference to programs that allocate a lot.
+- Weaknesses: Highly artificial -- allocation pattern is not real, and only
+ a few different size allocations are used.
+
sarp:
- Description: Does a lot of stack allocation and deallocation.
- Strengths: Tests for a specific performance bug that existed in 3.1.0 and
diff --git a/perf/heap.c b/perf/heap.c
new file mode 100644
index 000000000..c84f6cbfc
--- /dev/null
+++ b/perf/heap.c
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#define NLIVE 1000000
+
+#define NITERS (3*1000*1000)
+
+char* arr[NLIVE];
+
+int main ( void )
+{
+ int i, j, nbytes = 0;
+ printf("initialising\n");
+ for (i = 0; i < NLIVE; i++)
+ arr[i] = NULL;
+
+ printf("running\n");
+ j = -1;
+ for (i = 0; i < NITERS; i++) {
+ j++;
+ if (j == NLIVE) j = 0;
+ if (arr[j])
+ free(arr[j]);
+ arr[j] = malloc(nbytes);
+
+ // Cycle through the sizes 0,8,16,24,32. Zero will get rounded up to
+ // 8, so the 8B bucket will get twice as much traffic.
+ nbytes += 8;
+ if (nbytes > 32)
+ nbytes = 0;
+ }
+
+ for (i = 0; i < NLIVE; i++)
+ if (arr[i])
+ free(arr[i]);
+
+ printf("done\n");
+ return 0;
+}
diff --git a/perf/heap.vgperf b/perf/heap.vgperf
new file mode 100644
index 000000000..a3628015c
--- /dev/null
+++ b/perf/heap.vgperf
@@ -0,0 +1,2 @@
+prog: heap
+tools: none memcheck
diff --git a/perf/vg_perf.in b/perf/vg_perf.in
index 887cc9695..565f112b1 100644
--- a/perf/vg_perf.in
+++ b/perf/vg_perf.in
@@ -319,10 +319,10 @@ sub do_one_test($$)
# the speedup.
if (not defined $first_tTool{$tool}) {
$first_tTool{$tool} = $tTool;
- print(" -----) ");
+ print(" -----) ");
} else {
my $speedup = 100 - (100 * $tTool / $first_tTool{$tool});
- printf("%5.1f%%) ", $speedup);
+ printf("%5.1f%%) ", $speedup);
}
$num_timings_done++;