23 using namespace TCLAP;
26 #if (defined(_WIN32) || defined(_WIN64)) 33 int CPUInfo[4] = { -1 };
34 __cpuid(CPUInfo, 0x80000000);
35 unsigned int nExIds = CPUInfo[0];
38 char CPUBrandString[0x40] = { 0 };
39 for (
unsigned int i = 0x80000000;
i <= nExIds; ++
i)
46 memcpy(CPUBrandString,
50 else if (
i == 0x80000003)
52 memcpy(CPUBrandString + 16,
56 else if (
i == 0x80000004)
58 memcpy(CPUBrandString + 32, CPUInfo,
sizeof(CPUInfo));
62 char* ptr = CPUBrandString;
63 while (*ptr ==
' ') ptr++;
67 #elif defined __linux__ || defined(__linux__) 71 ifstream finfo(
"/proc/cpuinfo");
72 while(getline(finfo,line))
74 stringstream
str(line);
77 if (getline(
str, itype,
':') && getline(
str, info) && itype.substr(0, 10) ==
"model name")
85 string get_cpu() {
return "unknown"; }
108 return _block.process(f);
141 auto res = _upload.process(f);
159 vector<shared_ptr<test>>&
tests)
const = 0;
162 #define REGISTER_TEST(x) tests.push_back(make_shared<pb_test<x>>(#x)) 168 vector<shared_ptr<test>>&
tests)
const override 187 #define REGISTER_GL_TEST(x) tests.push_back(make_shared<gl_test<x>>(#x)) 193 vector<shared_ptr<test>>&
tests)
const override 207 int main(
int argc,
char** argv)
try 210 cmd.
parse(argc, argv);
222 cout <<
"| | |" << endl;
223 cout <<
"|------------|-----|" << endl;
226 cout <<
"|**GPU** | " << renderer <<
" |" << endl;
227 cout <<
"|**Graphics Driver** |" << version <<
" |" << endl;
229 vector<shared_ptr<suite>> suites;
230 suites.push_back(make_shared<processing_blocks>());
234 suites.push_back(make_shared<gl_blocks>());
241 auto prof = p.
start(cfg);
242 auto dev = prof.get_device();
244 cout <<
"|**Device Name** |" <<
name <<
" |" << endl << endl;
247 for (
auto stream : prof.get_streams())
249 cout <<
"**Stream Type**: " <<
stream.stream_name();
252 cout <<
", **Resolution**: " <<
vs.width() <<
" x " <<
vs.height() << endl;
256 vector<shared_ptr<test>> procs;
257 for (
auto&&
suite : suites)
261 for (
int i = 0;
i < 5 *
fps;
i++)
265 if (
f.get_profile().unique_id() ==
stream.unique_id())
273 cout <<
"|Filter Name |Step |Median(m) |Mean(m) |STD(m) |Max(m) | Max FPS |" << endl;
274 cout <<
"|------------|-----|------------|---------|--------|--------|---------|" << endl;
276 string last_name =
"";
277 for (
auto&& test : procs)
279 map<string, vector<double>> steps;
281 for (
auto&&
f : frames)
284 auto f1 = test->prepare(
f);
286 auto f2 = test->process(f1);
291 auto prep = duration_cast<microseconds>(
p2 -
p1).
count();
292 auto proc = duration_cast<microseconds>(p3 -
p2).
count();
293 auto down = duration_cast<microseconds>(p4 - p3).
count();
294 auto total = duration_cast<microseconds>(p4 -
p1).
count();
296 steps[
" Upload"].push_back(prep * 0.001);
297 steps[
"Calculate"].push_back(proc * 0.001);
298 steps[
"Download"].push_back(down * 0.001);
299 steps[
"Total"].push_back(total * 0.001);
302 int printed_steps = 0;
303 for (
auto&& sm : steps)
305 if (sm.first ==
"Total" && printed_steps < 2)
continue;
308 double max = *max_element(
m.begin(),
m.end());
309 double sum = accumulate(
m.begin(),
m.end(), 0.0);
310 double mean = sum /
m.size();
311 double sq_sum = inner_product(
m.begin(),
m.end(),
m.begin(), 0.0);
312 double stdev = sqrt(sq_sum /
m.size() - mean * mean);
314 double median =
m[
m.size() / 2];
316 vector<int> fps_values{ 6, 15, 30, 60, 90 };
318 auto expected_max = mean + 1.645 * stdev;
321 for (
int fps : fps_values)
323 auto max_allowed = 1000.0 /
fps;
324 if (expected_max < max_allowed) best_fps =
fps;
327 if (sm.first ==
"Calculate" || median > 0.001)
329 bool is_new = last_name != test->name();
330 bool is_total = sm.first ==
"Total";
331 cout <<
"|" << (is_new ? test->name() :
"")
332 <<
" |" << (is_total ?
"**" :
"") << sm.first << (is_total ?
"**" :
"") <<
" |" 333 << fixed << median <<
" |" << mean <<
" |" 334 << stdev <<
" |" << max <<
" |";
336 if (best_fps == 90)
cout <<
"90 ![90](https://placehold.it/15/35ff4d/000000?text=+)";
337 else if (best_fps == 60)
cout <<
"60 ![60](https://placehold.it/15/6fe837/000000?text=+)";
338 else if (best_fps == 30)
cout <<
"30 ![30](https://placehold.it/15/82c13e/000000?text=+)";
339 else if (best_fps == 15)
cout <<
"15 ![15](https://placehold.it/15/eff70c/000000?text=+)";
340 else if (best_fps == 6)
cout <<
"6 ![6](https://placehold.it/15/d6a726/000000?text=+)";
341 else cout <<
"? ![unknown](https://placehold.it/15/d65d26/000000?text=+)";
343 cout <<
" |" << endl;
346 last_name = test->name();
void init_processing(bool use_glsl=true)
frameset wait_for_frames(unsigned int timeout_ms=RS2_DEFAULT_TIMEOUT) const
GLuint const GLchar * name
The header of the GLFW 3 API.
int main(int argc, char **argv)
GLFWAPI GLFWglproc glfwGetProcAddress(const char *procname)
Returns the address of the specified function for the current context.
pb_test(std::string name)
void *(* GLADloadproc)(const char *name)
frame process(frame f) override
const void * get_data() const
GLsizei const GLchar *const * string
frame process(frame f) override
virtual void register_tests(stream_profile stream, vector< shared_ptr< test >> &tests) const =0
void sort(sort_type m_sort_type, const std::string &in, const std::string &out)
virtual const std::string & name() const override
def info(name, value, persistent=False)
const std::string & get_failed_args() const
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
void register_tests(stream_profile stream, vector< shared_ptr< test >> &tests) const override
frame prepare(frame f) override
GLFWAPI void glfwMakeContextCurrent(GLFWwindow *window)
Makes the context of the specified window current for the calling thread.
#define REGISTER_GL_TEST(x)
virtual frame prepare(frame f)
void enable_stream(rs2_stream stream_type, int stream_index, int width, int height, rs2_format format=RS2_FORMAT_ANY, int framerate=0)
GLAPI int gladLoadGLLoader(GLADloadproc)
virtual frame finish(frame f)
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
rs2_format format() const
void parse(int argc, const char *const *argv)
gl_test(std::string name)
#define RS2_API_VERSION_STR
#define GLFW_VISIBLE
Window visibility window hint and attribute.
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
frame finish(frame f) override
rs2_stream stream_type() const
GLFWAPI void glfwWindowHint(int hint, int value)
Sets the specified window hint to the desired value.
const std::string & get_failed_function() const
void register_tests(stream_profile stream, vector< shared_ptr< test >> &tests) const override