benchmark.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #ifndef __GEARMAN_BENCHMARK_H__
  13. #define __GEARMAN_BENCHMARK_H__
  14. #include "config.h"
  15. #include <libgearman/gearman.h>
  16. #ifdef HAVE_ERRNO_H
  17. #include <errno.h>
  18. #endif
  19. #ifdef HAVE_SIGNAL_H
  20. #include <signal.h>
  21. #endif
  22. #ifdef HAVE_STDIO_H
  23. #include <stdio.h>
  24. #endif
  25. #ifdef HAVE_STDLIB_H
  26. #include <stdlib.h>
  27. #endif
  28. #ifdef HAVE_STRING_H
  29. #include <string.h>
  30. #endif
  31. #ifdef HAVE_UNISTD_H
  32. #include <unistd.h>
  33. #endif
  34. #ifdef TIME_WITH_SYS_TIME
  35. # include <sys/time.h>
  36. # include <time.h>
  37. #else
  38. # ifdef HAVE_SYS_TIME_H
  39. # include <sys/time.h>
  40. # else
  41. # include <time.h>
  42. # endif
  43. #endif
  44. #define GEARMAN_BENCHMARK_DEFAULT_FUNCTION "gb"
  45. /**
  46. * @addtogroup benchmark Common Benchmark Utilities
  47. * @{
  48. */
  49. typedef struct
  50. {
  51. bool background;
  52. uint8_t verbose;
  53. uint64_t total_jobs;
  54. uint64_t jobs;
  55. struct timeval total;
  56. struct timeval begin;
  57. struct timeval end;
  58. } gearman_benchmark_st;
  59. /**
  60. * Initialize a benchmark strucutre.
  61. */
  62. void benchmark_init(gearman_benchmark_st *benchmark);
  63. /**
  64. * Check and possibly print time.
  65. */
  66. void benchmark_check_time(gearman_benchmark_st *benchmark);
  67. /** @} */
  68. #endif /* __GEARMAN_BENCHMARK_H__ */