Skip to content

Commit

Permalink
benchmarks: add group key to scenario
Browse files Browse the repository at this point in the history
The group value is printed in results header. It may be useful for
grouping results.
  • Loading branch information
plebioda committed Feb 29, 2016
1 parent 8784a02 commit 6f21707
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 9 deletions.
29 changes: 22 additions & 7 deletions src/benchmarks/config_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
#include "config_reader.h"

#define SECTION_GLOBAL "global"
#define SECTION_CONFIG "config"
#define KEY_BENCHMARK "bench"
#define KEY_GROUP "group"

/*
* config_reader -- handle structure
Expand Down Expand Up @@ -105,10 +105,7 @@ config_reader_free(struct config_reader *cr)
static int
is_scenario(const char *name)
{
if (strcmp(name, SECTION_GLOBAL) == 0 ||
strcmp(name, SECTION_CONFIG) == 0)
return 0;
return 1;
return strcmp(name, SECTION_GLOBAL);
}

/*
Expand All @@ -119,7 +116,8 @@ is_scenario(const char *name)
static int
is_argument(const char *name)
{
return strcmp(name, KEY_BENCHMARK);
return strcmp(name, KEY_BENCHMARK) != 0 &&
strcmp(name, KEY_GROUP) != 0;
}

/*
Expand Down Expand Up @@ -173,7 +171,7 @@ config_reader_get_scenarios(struct config_reader *cr,
for (g = 0; g < ngroups; g++) {
/*
* Check whether a group is a scenario
* or global or config sections.
* or global section.
*/
if (!is_scenario(groups[g]))
continue;
Expand Down Expand Up @@ -211,6 +209,9 @@ config_reader_get_scenarios(struct config_reader *cr,
gkeys[k], NULL) == TRUE)
continue;

if (!is_argument(gkeys[k]))
continue;

char *value = g_key_file_get_value(cr->key_file,
SECTION_GLOBAL,
gkeys[k], NULL);
Expand All @@ -233,6 +234,20 @@ config_reader_get_scenarios(struct config_reader *cr,
}
}

/* check for group name */
if (g_key_file_has_key(cr->key_file, groups[g],
KEY_GROUP, NULL) != FALSE) {
gchar *group = g_key_file_get_value(cr->key_file,
groups[g], KEY_GROUP, NULL);
assert(group != NULL);
scenario_set_group(scenario, group);
} else if (g_key_file_has_key(cr->key_file, SECTION_GLOBAL,
KEY_GROUP, NULL) != FALSE) {
gchar *group = g_key_file_get_value(cr->key_file,
SECTION_GLOBAL, KEY_GROUP, NULL);
scenario_set_group(scenario, group);
}

gsize nkeys;
gchar **keys = g_key_file_get_keys(cr->key_file, groups[g],
&nkeys, NULL);
Expand Down
9 changes: 7 additions & 2 deletions src/benchmarks/pmembench.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,13 @@ pmembench_print_header(struct pmembench *pb, struct benchmark *bench,
struct clo_vec *clovec)
{
if (pb->scenario) {
printf("%s: %s [%ld]\n", pb->scenario->name,
bench->info->name, clovec->nargs);
printf("%s: %s [%ld]%s%s%s\n",
pb->scenario->name,
bench->info->name,
clovec->nargs,
pb->scenario->group ? " [group: " : "",
pb->scenario->group ? : "",
pb->scenario->group ? "]" : "");
} else {
printf("%s [%ld]\n", bench->info->name, clovec->nargs);
}
Expand Down
1 change: 1 addition & 0 deletions src/benchmarks/pmembench_atomic_lists.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Global parameters
[global]
group = pmemobj
file = testfile.list
ops-per-thread = 10000

Expand Down
1 change: 1 addition & 0 deletions src/benchmarks/pmembench_blk.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Global parameters
[global]
group = pmemblk
file = testfile.blk
ops-per-thread=1000

Expand Down
1 change: 1 addition & 0 deletions src/benchmarks/pmembench_log.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# Global parameters
[global]
group = pmemlog
file = testfile.log
ops-per-thread = 1000

Expand Down
1 change: 1 addition & 0 deletions src/benchmarks/pmembench_map.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[global]
group = pmemobj
file = testfile.map
ops-per-thread=1000000
threads=1
Expand Down
1 change: 1 addition & 0 deletions src/benchmarks/pmembench_memcpy.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Global parameters
[global]
group = pmem
file = testfile.memcpy
ops-per-thread=50000

Expand Down
1 change: 1 addition & 0 deletions src/benchmarks/pmembench_memset.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# Global parameters
[global]
group = pmem
file = testfile.memset
ops-per-thread = 10000

Expand Down
1 change: 1 addition & 0 deletions src/benchmarks/pmembench_obj_gen.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Global parameters
[global]
group = pmemobj
file = testfile.obj
ops-per-thread = 100

Expand Down
1 change: 1 addition & 0 deletions src/benchmarks/pmembench_obj_lanes.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Global parameters
[global]
group = pmemobj
file = ./testfile.lane
ops-per-thread = 100000
threads = 1:*2:32
Expand Down
1 change: 1 addition & 0 deletions src/benchmarks/pmembench_obj_locks.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Global parameters
[global]
group = pmemobj
file = ./testfile.locks
ops-per-thread = 1000000:*10:10000000

Expand Down
1 change: 1 addition & 0 deletions src/benchmarks/pmembench_obj_pmalloc.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Global parameters
[global]
group = pmemobj
file = ./testfile.pmalloc
data-size = 64:*2:262144

Expand Down
1 change: 1 addition & 0 deletions src/benchmarks/pmembench_tx.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Global parameters
[global]
file = /dev/shm/testfile.tx
group = pmemobj
ops-per-thread = 100

# obj_tx_alloc benchmark
Expand Down
1 change: 1 addition & 0 deletions src/benchmarks/pmembench_vmem.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Global parameters
[global]
group = vmem
file = testdir.vmem
ops-per-thread = 100000

Expand Down
13 changes: 13 additions & 0 deletions src/benchmarks/scenario.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ scenario_alloc(const char *name, const char *bench)
s->benchmark = strdup(bench);
assert(s->benchmark != NULL);

s->group = NULL;

return s;
}

Expand All @@ -102,11 +104,22 @@ scenario_free(struct scenario *s)
kv_free(kv);
}

free(s->group);
free(s->name);
free(s->benchmark);
free(s);
}

/*
* scenario_set_group -- set group of scenario
*/
void
scenario_set_group(struct scenario *s, const char *group)
{
assert(s != NULL);
s->group = strdup(group);
}

/*
* scenarios_alloc -- allocate scenarios structure
*/
Expand Down
2 changes: 2 additions & 0 deletions src/benchmarks/scenario.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct scenario
TAILQ_HEAD(scenariohead, kv) head;
char *name;
char *benchmark;
char *group;
};

struct scenarios
Expand All @@ -63,6 +64,7 @@ void kv_free(struct kv *kv);

struct scenario *scenario_alloc(const char *name, const char *bench);
void scenario_free(struct scenario *s);
void scenario_set_group(struct scenario *s, const char *group);

struct scenarios *scenarios_alloc(void);
void scenarios_free(struct scenarios *scenarios);
Expand Down

0 comments on commit 6f21707

Please sign in to comment.