Skip to content

Commit

Permalink
size in csv: bytes instead of overhead in percents
Browse files Browse the repository at this point in the history
  • Loading branch information
beling committed Mar 10, 2024
1 parent 548f9a9 commit be377e6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
33 changes: 16 additions & 17 deletions cseq_benchmark/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ pub struct Conf {
}

const INPUT_HEADER: &'static str = "universe,num,distribution";
const RANK_SELECT_HEADER: &'static str = "method,space_overhead,time_per_query";
const RANK_HEADER: &'static str = "method,size,time_per_query";
const SELECT_HEADER: &'static str = "method,extra_size,time_per_query";

/// Tester that knows configuration and real number of items.
struct Tester<'c> {
Expand Down Expand Up @@ -141,7 +142,7 @@ impl<'c> Tester<'c> {
print!(" rank: space overhead {:.2}%", self.conf.space_overhead(size_bytes));
let time = self.conf.queries_measure(&self.conf.rand_queries(self.conf.universe), &rank).as_nanos();
println!(" time/query {:.2}ns", time);
self.conf.save_rank(method_name, self.conf.space_overhead(size_bytes), time);
self.conf.save_rank(method_name, size_bytes, time);
self.verify_rank(method_name, rank);
}

Expand All @@ -166,11 +167,10 @@ impl<'c> Tester<'c> {
return;
}
print!(" select1:");
let space_overhead = self.conf.extra_space_overhead(extra_size_bytes);
if extra_size_bytes != 0 { print!(" space overhead {:.2}%", space_overhead); }
if extra_size_bytes != 0 { print!(" space overhead {:.2}%", self.conf.extra_space_overhead(extra_size_bytes)); }
let time = self.conf.queries_measure(&self.conf.rand_queries(self.number_of_ones), &select).as_nanos();
println!(" time/query {:.2}ns", time);
self.conf.save_select1(method_name, space_overhead, time);
self.conf.save_select1(method_name, extra_size_bytes, time);
self.verify_select1(method_name, select);
}

Expand All @@ -194,13 +194,12 @@ impl<'c> Tester<'c> {
return;
}
print!(" select0:");
let space_overhead = self.conf.extra_space_overhead(extra_size_bytes);
if extra_size_bytes != 0 { print!(" space overhead {:.2}%", space_overhead); }
if extra_size_bytes != 0 { print!(" space overhead {:.2}%", self.conf.extra_space_overhead(extra_size_bytes)); }
let time = self.conf.queries_measure(
&self.conf.rand_queries(self.conf.universe-self.number_of_ones),
&select0).as_nanos();
println!(" time/query {:.2}ns", time);
self.conf.save_select0(method_name, space_overhead, time);
self.conf.save_select0(method_name, extra_size_bytes, time);
self.verify_select0(method_name, select0);
}

Expand Down Expand Up @@ -315,25 +314,25 @@ impl Conf {

/// Saves `space_overhead` and `time` per *rank* or *select* query (in ns) of method with given `method_name`
/// to file with given `file_name` (+`csv` extension).
fn save_rank_or_select(&self, file_name: &str, method_name: &str, space_overhead: f64, time: f64) {
if let Some(mut file) = self.file(file_name, RANK_SELECT_HEADER) {
writeln!(file, "{},{},{},{},{},{}", self.universe, self.num, self.distribution, method_name, space_overhead, time).unwrap();
fn save_rank_or_select(&self, header: &str, file_name: &str, method_name: &str, space: usize, time: f64) {
if let Some(mut file) = self.file(file_name, header) {
writeln!(file, "{},{},{},{},{},{}", self.universe, self.num, self.distribution, method_name, space, time).unwrap();
}
}

/// Saves `space_overhead` and `time` per *rank* query (in ns) of method with given `method_name` to `rank.csv`.
pub fn save_rank(&self, method_name: &str, space_overhead: f64, time: f64) {
self.save_rank_or_select("rank", method_name, space_overhead, time)
pub fn save_rank(&self, method_name: &str, space_bytes: usize, time: f64) {
self.save_rank_or_select(RANK_HEADER, "rank", method_name, space_bytes, time)
}

/// Saves `space_overhead` and `time` per *select1* query (in ns) of method with given `method_name` to `select1.csv`.
pub fn save_select1(&self, method_name: &str, space_overhead: f64, time: f64) {
self.save_rank_or_select("select1", method_name, space_overhead, time)
pub fn save_select1(&self, method_name: &str, extra_size_bytes: usize, time: f64) {
self.save_rank_or_select(SELECT_HEADER, "select1", method_name, extra_size_bytes, time)
}

/// Saves `space_overhead` and `time` per *select0* query (in ns) of method with given `method_name` to `select0.csv`.
pub fn save_select0(&self, method_name: &str, space_overhead: f64, time: f64) {
self.save_rank_or_select("select0", method_name, space_overhead, time)
pub fn save_select0(&self, method_name: &str, extra_size_bytes: usize, time: f64) {
self.save_rank_or_select(SELECT_HEADER, "select0", method_name, extra_size_bytes, time)
}

/// Returns random number generator.
Expand Down
3 changes: 2 additions & 1 deletion cseq_benchmark/utils/cseq_benchmark_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def gen_tab(filename, params={}, filter=None):
return
if filename.startswith('select'): d["method"] = d["method"].apply(process_alg_name)
d["percent of ones"] = (d["num"]*100/d["universe"]).round(0).astype(int)
d["space overhead [%]"] = d["space_overhead"].round(1)
d["raw_size"] = (d["universe"] + 7) // 8
d["space overhead [%]"] = ((d["size"] - d["raw_size"] if 'size' in d else d["extra_size"]) * 100 / d["raw_size"]).round(1)
d["time / query [ns]"] = d["time_per_query"].round(0).astype(int)
if filter is not None: d = d[filter(d)]
#d["universe"] = d["universe"].apply(exp_str)
Expand Down

0 comments on commit be377e6

Please sign in to comment.