Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 288609
b: refs/heads/master
c: e3e877e
h: refs/heads/master
i:
  288607: 3a7341b
v: v3
  • Loading branch information
Jan Beulich authored and Arnaldo Carvalho de Melo committed Jan 24, 2012
1 parent fa4fa20 commit e308edf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: be3de80dc2e671d9ee15e69fe9cd84d2b71e2225
refs/heads/master: e3e877e79b7c6a322f9f628e87052c13581238cc
11 changes: 9 additions & 2 deletions trunk/tools/perf/bench/mem-memcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

static const char *length_str = "1MB";
static const char *routine = "default";
static int iterations = 1;
static bool use_clock;
static int clock_fd;
static bool only_prefault;
Expand All @@ -35,6 +36,8 @@ static const struct option options[] = {
"available unit: B, MB, GB (upper and lower)"),
OPT_STRING('r', "routine", &routine, "default",
"Specify routine to copy"),
OPT_INTEGER('i', "iterations", &iterations,
"repeat memcpy() invocation this number of times"),
OPT_BOOLEAN('c', "clock", &use_clock,
"Use CPU clock for measuring"),
OPT_BOOLEAN('o', "only-prefault", &only_prefault,
Expand Down Expand Up @@ -121,14 +124,16 @@ static u64 do_memcpy_clock(memcpy_t fn, size_t len, bool prefault)
{
u64 clock_start = 0ULL, clock_end = 0ULL;
void *src = NULL, *dst = NULL;
int i;

alloc_mem(&src, &dst, len);

if (prefault)
fn(dst, src, len);

clock_start = get_clock();
fn(dst, src, len);
for (i = 0; i < iterations; ++i)
fn(dst, src, len);
clock_end = get_clock();

free(src);
Expand All @@ -140,14 +145,16 @@ static double do_memcpy_gettimeofday(memcpy_t fn, size_t len, bool prefault)
{
struct timeval tv_start, tv_end, tv_diff;
void *src = NULL, *dst = NULL;
int i;

alloc_mem(&src, &dst, len);

if (prefault)
fn(dst, src, len);

BUG_ON(gettimeofday(&tv_start, NULL));
fn(dst, src, len);
for (i = 0; i < iterations; ++i)
fn(dst, src, len);
BUG_ON(gettimeofday(&tv_end, NULL));

timersub(&tv_end, &tv_start, &tv_diff);
Expand Down
11 changes: 9 additions & 2 deletions trunk/tools/perf/bench/mem-memset.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

static const char *length_str = "1MB";
static const char *routine = "default";
static int iterations = 1;
static bool use_clock;
static int clock_fd;
static bool only_prefault;
Expand All @@ -35,6 +36,8 @@ static const struct option options[] = {
"available unit: B, MB, GB (upper and lower)"),
OPT_STRING('r', "routine", &routine, "default",
"Specify routine to copy"),
OPT_INTEGER('i', "iterations", &iterations,
"repeat memset() invocation this number of times"),
OPT_BOOLEAN('c', "clock", &use_clock,
"Use CPU clock for measuring"),
OPT_BOOLEAN('o', "only-prefault", &only_prefault,
Expand Down Expand Up @@ -117,14 +120,16 @@ static u64 do_memset_clock(memset_t fn, size_t len, bool prefault)
{
u64 clock_start = 0ULL, clock_end = 0ULL;
void *dst = NULL;
int i;

alloc_mem(&dst, len);

if (prefault)
fn(dst, -1, len);

clock_start = get_clock();
fn(dst, 0, len);
for (i = 0; i < iterations; ++i)
fn(dst, i, len);
clock_end = get_clock();

free(dst);
Expand All @@ -135,14 +140,16 @@ static double do_memset_gettimeofday(memset_t fn, size_t len, bool prefault)
{
struct timeval tv_start, tv_end, tv_diff;
void *dst = NULL;
int i;

alloc_mem(&dst, len);

if (prefault)
fn(dst, -1, len);

BUG_ON(gettimeofday(&tv_start, NULL));
fn(dst, 0, len);
for (i = 0; i < iterations; ++i)
fn(dst, i, len);
BUG_ON(gettimeofday(&tv_end, NULL));

timersub(&tv_end, &tv_start, &tv_diff);
Expand Down

0 comments on commit e308edf

Please sign in to comment.