benchmark.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #include <string>
  15. #include <stdint.h>
  16. #ifndef BENCHMARK_H
  17. #define BENCHMARK_H
  18. class uBenchmark {
  19. public:
  20. uBenchmark(uint32_t iterations, const std::string& dbname,
  21. bool sync, bool verbose,
  22. const std::string& host = "",
  23. const std::string& username = "",
  24. const std::string& pass = "");
  25. virtual void printInfo() = 0;
  26. virtual void connect() = 0;
  27. virtual void disconnect() = 0;
  28. virtual void createLease4Test() = 0;
  29. virtual void searchLease4Test() = 0;
  30. virtual void updateLease4Test() = 0;
  31. virtual void deleteLease4Test() = 0;
  32. virtual void failure(const char* operation);
  33. void print_clock(const std::string& operation, uint32_t num,
  34. const struct timespec& before,
  35. const struct timespec& after);
  36. int run();
  37. bool parseCmdline(int args, const char* argv[]);
  38. protected:
  39. uint32_t Num_; // number of operations (e.g. insert lease num times)
  40. bool Sync_; // synchronous or asynchonous mode?
  41. bool Verbose_;
  42. std::string Hostname_;// used by MySQL only
  43. std::string User_; // used by MySQL only
  44. std::string Passwd_; // used by MySQL only
  45. std::string DBName_; // used by MySQL, SQLite and memfile
  46. const static uint32_t BASE_ADDR4 = 0x01000000; // let's start from 1.0.0.0 address
  47. // five timestamps (1 at the beginning and 4 after each step)
  48. struct timespec ts[5];
  49. };
  50. #endif