benchmark.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 numInterations);
  21. virtual void printInfo() = 0;
  22. virtual void connect() = 0;
  23. virtual void disconnect() = 0;
  24. virtual void createLease4Test() = 0;
  25. virtual void searchLease4Test() = 0;
  26. virtual void updateLease4Test() = 0;
  27. virtual void deleteLease4Test() = 0;
  28. virtual void failure(const char* operation);
  29. void print_clock(const std::string& operation, uint32_t num,
  30. const struct timespec& before,
  31. const struct timespec& after);
  32. int run();
  33. protected:
  34. uint32_t Num_; // number of operations (e.g. insert lease num times)
  35. const static uint32_t BASE_ADDR4 = 0x01000000; // let's start from 1.0.0.0 address
  36. // five timestamps (1 at the beginning and 4 after each step)
  37. struct timespec ts[5];
  38. };
  39. #endif