mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-04-20 14:58:54 +00:00
Finish off proof of concept level functionality.
Add `measure_hot` and `markdown_format` as detail classes, since they're still pretty rough and need to be worked into the design. But for now, they're functional proofs of concept. The formatting is rough, but demonstrates basics. Also added launch, exec, and summary functionality. These aren't details and will be part of the project's API.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <nvbench/state.cuh>
|
||||
|
||||
#include <nvbench/summary.cuh>
|
||||
#include <nvbench/types.cuh>
|
||||
|
||||
#include "test_asserts.cuh"
|
||||
@@ -23,14 +24,49 @@ struct state_tester : public nvbench::state
|
||||
void test_params()
|
||||
{
|
||||
// Build a state param by param
|
||||
state_tester state1;
|
||||
state1.set_param("TestInt", nvbench::int64_t{22});
|
||||
state1.set_param("TestFloat", nvbench::float64_t{3.14});
|
||||
state1.set_param("TestString", "A String!");
|
||||
state_tester state;
|
||||
state.set_param("TestInt", nvbench::int64_t{22});
|
||||
state.set_param("TestFloat", nvbench::float64_t{3.14});
|
||||
state.set_param("TestString", "A String!");
|
||||
|
||||
ASSERT(state1.get_int64("TestInt") == nvbench::int64_t{22});
|
||||
ASSERT(state1.get_float64("TestFloat") == nvbench::float64_t{3.14});
|
||||
ASSERT(state1.get_string("TestString") == "A String!");
|
||||
ASSERT(state.get_int64("TestInt") == nvbench::int64_t{22});
|
||||
ASSERT(state.get_float64("TestFloat") == nvbench::float64_t{3.14});
|
||||
ASSERT(state.get_string("TestString") == "A String!");
|
||||
}
|
||||
|
||||
int main() { test_params(); }
|
||||
void test_summaries()
|
||||
{
|
||||
state_tester state;
|
||||
ASSERT(state.get_summaries().size() == 0);
|
||||
|
||||
{
|
||||
nvbench::summary& summary = state.add_summary("Test Summary1");
|
||||
summary.set_float64("Float", 3.14);
|
||||
summary.set_int64("Int", 128);
|
||||
summary.set_string("String", "str");
|
||||
}
|
||||
|
||||
ASSERT(state.get_summaries().size() == 1);
|
||||
ASSERT(state.get_summary("Test Summary1").get_size() == 3);
|
||||
ASSERT(state.get_summary("Test Summary1").get_float64("Float") == 3.14);
|
||||
ASSERT(state.get_summary("Test Summary1").get_int64("Int") == 128);
|
||||
ASSERT(state.get_summary("Test Summary1").get_string("String") == "str");
|
||||
|
||||
{
|
||||
nvbench::summary summary{"Test Summary2"};
|
||||
state.add_summary(std::move(summary));
|
||||
}
|
||||
|
||||
ASSERT(state.get_summaries().size() == 2);
|
||||
ASSERT(state.get_summary("Test Summary1").get_size() == 3);
|
||||
ASSERT(state.get_summary("Test Summary1").get_float64("Float") == 3.14);
|
||||
ASSERT(state.get_summary("Test Summary1").get_int64("Int") == 128);
|
||||
ASSERT(state.get_summary("Test Summary1").get_string("String") == "str");
|
||||
ASSERT(state.get_summary("Test Summary2").get_size() == 0);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_params();
|
||||
test_summaries();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user