Skip to content

Commit

Permalink
Allow running the perf_report target on any platform.
Browse files Browse the repository at this point in the history
On Linux, it generates the additional system info files. Other than
that, functionality is the same.
  • Loading branch information
jvirkki committed Oct 7, 2015
1 parent 391c9d5 commit 1c63744
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# make gcov to build with code coverage and run gcov
# make lint to run lint
# make clean the usual
# make perf_report (Linux only) generate perf reports (see README.perf)
# make perf_report generate perf reports (see README.perf)
#

BLOOM_VERSION=1.2
Expand All @@ -32,7 +32,7 @@ LIB=-lm
CC=gcc -Wall ${OPT} ${MM} -std=c99 -fPIC -D_GNU_SOURCE -DBLOOM_VERSION=$(BLOOM_VERSION)

#
# Defines used by the perf_test target (Linux-specific)
# Defines used by the perf_test target
#
HEAD=$(shell git log -1 --format="%h_%f")
ifndef HOSTNAME
Expand All @@ -53,6 +53,7 @@ RPATH=-Wl,-rpath,$(BUILD)
SO=so
LINUX_BO=$(BUILD)/linux.o
LINUX_O=linux.o
PERF_STAT=perf stat --log-fd 1
endif

ifeq ($(BUILD_OS),SunOS)
Expand Down Expand Up @@ -98,13 +99,14 @@ lint:
test: $(BUILD)/test-libbloom
$(BUILD)/test-libbloom

ifeq ($(BUILD_OS),Linux)

.PHONY: perf_report
perf_report: $(BUILD)/test-libbloom
mkdir -p $(PERF_TEST_DIR_CPU)
perf stat --log-fd 1 $(BUILD)/test-libbloom -p 5000000 5000000 | tee $(PERF_TEST_DIR_CPU)/test_1.log
perf stat --log-fd 1 $(BUILD)/test-libbloom -p 10000000 10000000 | tee $(PERF_TEST_DIR_CPU)/test_2.log
perf stat --log-fd 1 $(BUILD)/test-libbloom -p 50000000 50000000 | tee $(PERF_TEST_DIR_CPU)/test_3.log
$(PERF_STAT) $(BUILD)/test-libbloom -p 5000000 5000000 | tee $(PERF_TEST_DIR_CPU)/test_1.log
$(PERF_STAT) $(BUILD)/test-libbloom -p 10000000 10000000 | tee $(PERF_TEST_DIR_CPU)/test_2.log
$(PERF_STAT) $(BUILD)/test-libbloom -p 50000000 50000000 | tee $(PERF_TEST_DIR_CPU)/test_3.log
ifeq ($(BUILD_OS),Linux)
lscpu > ${PERF_TEST_DIR_CPU}/lscpu.log
inxi -Cm -c0 > ${PERF_TEST_DIR_CPU}/inxi.log 2>/dev/null || inxi -C -c0 > ${PERF_TEST_DIR_CPU}/inxi.log
endif
Expand Down
15 changes: 5 additions & 10 deletions README.perf
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,24 @@ The make target perf_report will run the perf test (from test.c) and
create some stats organized by current HEAD and CPU type. These are
useful for comparing changes between commits.

NOTE: Running the perf_report requires the following tools to be available:
- git
- inxi
- lscpu
- perf
- perl
Effectively, this means that the perf reports are Linux-specific.

Note that to generate the full inxi report you need to run it as root
(inxi -m requires root to use dmidecode). However, this is only needed
to generate the expected inxi.log file (see below). During regular
development/testing and/or if you'd rather not run it as root, all the
tests and reports will work fine as a regular user.

The following files will be generated under ./perf_reports/%h_%f/$HOSTNAME_$CPUID/
inxi.log - System info from inxi
lscpu.log - CPU info from lscpu
inxi.log - System info from inxi (Linux only)
lscpu.log - CPU info from lscpu (Linux only)
test_1.log - Test run and perf stats output, 5 million entries
test_2.log - Test run and perf stats output, 10 million entries
test_3.log - Test run and perf stats output, 50 million entries
%h = git abbreviated commit tag for most recent commit (see git log)
%f = git commit title, sanitized (see git log)

(Note that $CPUID above is generated using perf_reports/cpu_id on
Linux only. On other platforms, it contains the output of 'uname'.)

In other words, to generate a final report for a given commit you'll
want to commit the finalized changes and then run perf_report.

Expand Down
11 changes: 7 additions & 4 deletions perf_reports/cpu_id
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/usr/bin/perl

open LSCPU, "lscpu |" or die;
open LSCPU, "lscpu |" or print `uname`;
while (<LSCPU>)
{
/(.+?):\s+(.+)/;
$x{$1} = $2;
/(.+?):\s+(.+)/;
$x{$1} = $2;
$found = 1;
}

print "$x{'Vendor ID'}-$x{'CPU family'}.$x{Model}.$x{Stepping}_$x{'L1d cache'}\n"
if ($found) {
print "$x{'Vendor ID'}-$x{'CPU family'}.$x{Model}.$x{Stepping}_$x{'L1d cache'}\n"
}

0 comments on commit 1c63744

Please sign in to comment.