benchmark.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Gearman server and library
  2. * Copyright (C) 2008 Brian Aker, Eric Day
  3. * All rights reserved.
  4. *
  5. * Use and distribution licensed under the BSD license. See
  6. * the COPYING file in the parent directory for full text.
  7. */
  8. /**
  9. * @file
  10. * @brief Common benchmark header
  11. */
  12. #pragma once
  13. #include <libgearman/gearman.h>
  14. #ifdef TIME_WITH_SYS_TIME
  15. # include <sys/time.h>
  16. # include <time.h>
  17. #else
  18. # ifdef HAVE_SYS_TIME_H
  19. # include <sys/time.h>
  20. # else
  21. # include <time.h>
  22. # endif
  23. #endif
  24. #define GEARMAN_BENCHMARK_DEFAULT_FUNCTION "gb"
  25. /**
  26. * @addtogroup benchmark Common Benchmark Utilities
  27. * @{
  28. */
  29. struct gearman_benchmark_st
  30. {
  31. bool background;
  32. uint8_t verbose;
  33. uint64_t total_jobs;
  34. uint64_t jobs;
  35. struct timeval total;
  36. struct timeval begin;
  37. struct timeval end;
  38. gearman_benchmark_st() :
  39. background(false),
  40. verbose(0),
  41. total_jobs(0),
  42. jobs(0),
  43. end()
  44. {
  45. gettimeofday(&total, NULL);
  46. gettimeofday(&begin, NULL);
  47. }
  48. };
  49. /**
  50. * Check and possibly print time.
  51. */
  52. void benchmark_check_time(gearman_benchmark_st *benchmark);