lmbench.3 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. .\"
  2. .\" @(#)lmbench.man 2.0 98/04/24
  3. .\"
  4. .\" lmbench - benchmarking toolbox
  5. .\"
  6. .\" Copyright (C) 1998 Carl Staelin and Larry McVoy
  7. .\" E-mail: staelin@hpl.hp.com
  8. .\"
  9. .TH "LMBENCH" 3 "$Date$" "(c)1998 Larry McVoy" "LMBENCH"
  10. .SH "NAME"
  11. lmbench \- benchmarking toolbox
  12. .SH "SYNOPSIS"
  13. .ft C
  14. #include "lmbench.h"
  15. .br
  16. BENCH(loop_body, enough)
  17. .br
  18. BENCH1(loop_body, enough)
  19. .br
  20. uint64 get_n();
  21. .br
  22. void milli(char *s, uint64 n);
  23. .br
  24. void micro(char *s, uint64 n);
  25. .br
  26. void nano(char *s, uint64 n);
  27. .br
  28. void mb(uint64 bytes);
  29. .br
  30. void kb(uint64 bytes);
  31. .ft R
  32. .SH "DESCRIPTION"
  33. Creating benchmarks using the
  34. .I lmbench
  35. timing harness is easy.
  36. Since it is so easy to measure performance using
  37. .I lmbench ,
  38. it is possible to quickly answer questions that arise during system
  39. design, development, or tuning. For example, image processing
  40. .P
  41. There are two attributes that are critical for performance, latency
  42. and bandwidth, and
  43. .I lmbench's
  44. timing harness makes it easy to measure and report results for both.
  45. The measurement interface,
  46. .B BENCH
  47. and
  48. .BR BENCH1 ,
  49. are identical, but the reporting functions are different.
  50. Latency is usually important for frequently executed operations, and
  51. bandwidth is usually important when moving large chunks of data.
  52. .P
  53. There are a number of factors to consider when building benchmarks.
  54. .P
  55. The timing harness requires that the benchmarked operation
  56. be idempotent so that it can be repeated indefinitely.
  57. .P
  58. The timing subsystem includes two macros,
  59. .B BENCH
  60. and
  61. .BR BENCH1 ,
  62. which provide a uniform method for conducting experiments.
  63. .B BENCH1
  64. does one experiment and saves the result, while
  65. .B BENCH
  66. does eleven
  67. experiments and saves the median result.
  68. .TP
  69. .B "BENCH(loop_body, enough)"
  70. measures the performance of
  71. .I loop_body
  72. repeatedly and report the median result.
  73. .TP
  74. .B "BENCH1(loop_body, enough)"
  75. measures the performance of
  76. .I loop_body
  77. once.
  78. .TP
  79. .B "uint64 get_n()"
  80. returns the number of times
  81. .I loop_body
  82. was executed during the timing interval.
  83. .TP
  84. .B "void milli(char *s, uint64 n)"
  85. print out the time per operation in milli-seconds.
  86. .I n
  87. is the number of operations during the timing interval, which is passed
  88. as a parameter because each
  89. .I loop_body
  90. can contain several operations.
  91. .TP
  92. .B "void micro(char *s, uint64 n)"
  93. print the time per opertaion in micro-seconds.
  94. .TP
  95. .B "void nano(char *s, uint64 n)"
  96. print the time per operation in nano-seconds.
  97. .TP
  98. .B "void mb(uint64 bytes)"
  99. print the bandwidth in megabytes per second.
  100. .TP
  101. .B "void kb(uint64 bytes)"
  102. print the bandwidth in kilobytes per second.
  103. .SH "USING lmbench"
  104. Here is an example of a simple benchmark that measures the latency
  105. of the random number generator
  106. .BR lrand48() :
  107. .ft C
  108. .IP
  109. #include "lmbench.h"
  110. .br
  111. int
  112. .br
  113. main(int argc, char *argv[])
  114. .br
  115. {
  116. .br
  117. BENCH(lrand48(), 0);
  118. .br
  119. micro("lrand48()", get_n());
  120. .br
  121. exit(0);
  122. .br
  123. }
  124. .ft R
  125. .br
  126. .P
  127. Here is a simple benchmark that measures and reports the bandwidth of
  128. .BR copy() :
  129. .ft C
  130. .IP
  131. #include "lmbench.h"
  132. .br
  133. int
  134. .br
  135. main(int argc, char *argv[])
  136. .br
  137. {
  138. .br
  139. char *a = malloc(1024 * 1024);
  140. .br
  141. char *b = malloc(1024 * 1024);
  142. .br
  143. BENCH(bcopy(a, b, 1024*1024), 0);
  144. .br
  145. mb(get_n()*1024*1024);
  146. .br
  147. exit(0);
  148. .br
  149. }
  150. .ft R
  151. .SH "VARIABLES"
  152. There are three environment variables that can be used to modify the
  153. .I lmbench
  154. timing subsystem: ENOUGH, TIMING_O, and LOOP_O.
  155. .SH "FUTURES"
  156. Development of
  157. .I lmbench
  158. is continuing.
  159. .SH "SEE ALSO"
  160. lmbench(8), timing(3), reporting(3), results(3).
  161. .SH "AUTHOR"
  162. Carl Staelin and Larry McVoy.
  163. .PP
  164. Comments, suggestions, and bug reports are always welcome.