49 #include <visp/vpConfig.h>
50 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
54 # include <mmsystem.h>
61 #include <visp/vpTime.h>
62 #include <visp/vpParseArgv.h>
64 void usage(
const char *name,
const char *badparam);
65 bool getOptions(
int argc,
const char **argv);
68 #define GETOPTARGS "h"
75 void usage(
const char *name,
const char *badparam)
89 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
98 bool getOptions(
int argc,
const char **argv)
105 case 'h': usage(argv[0], NULL);
return false;
break;
108 usage(argv[0], optarg_);
113 if ((c == 1) || (c == -1)) {
115 usage(argv[0], NULL);
116 std::cerr <<
"ERROR: " << std::endl;
117 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
126 main(
int argc,
const char ** argv)
130 if (getOptions(argc, argv) ==
false) {
137 for (
int i =0 ; i < 100000; i ++)
138 for (
int j =0 ; j < 100; j ++)
140 std::cout <<
"Computed dummy value: " << v << std::endl;
148 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
150 #elif defined(_WIN32)
157 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
159 #elif defined(_WIN32)
180 std::cout <<
"t1-t0: computation time: " << t1 - t0 << std::endl;
181 std::cout <<
"t2-t1: wait(t1, 40 ms): " << t2 - t1 << std::endl;
182 std::cout <<
"t3-t2: sleep(10 ms): " << t3 - t2 << std::endl;
183 std::cout <<
"t4-t3: sleep(2 ms): " << t4 - t3 << std::endl;
184 std::cout <<
"t5-t4: wait(t, 19 ms): " << t5 - t4 << std::endl;
185 std::cout <<
"t6-t5: wait(5 ms): " << t6 - t5 << std::endl;
186 std::cout <<
"t7-t6: wait(21 ms): " << t7 - t6 << std::endl;
187 std::cout <<
"t8-t7: wait(2 ms): " << t8 - t7 << std::endl;
192 std::cout <<
"Catch an exception: " << e << std::endl;
error that can be emited by ViSP classes.
static double measureTimeMs()
static int wait(double t0, double t)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)