benchmark_devel.xml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?xml version="1.0" encoding='ISO-8859-1'?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  4. <!-- Include general documentation entities -->
  5. <!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
  6. %docentities;
  7. ]>
  8. <!-- Module Developer's Guide -->
  9. <chapter>
  10. <title>&develguide;</title>
  11. <para>
  12. The benchmark module provides an internal <acronym>API</acronym> to be used by
  13. other &kamailio; modules. The available functions are identical to the user exported
  14. functions.
  15. </para>
  16. <para>
  17. Please note that this module is intended mainly for developers. It should
  18. be used with caution in production environments.
  19. </para>
  20. <section>
  21. <title>Available Functions</title>
  22. <section>
  23. <title>
  24. <function moreinfo="none">bm_register(name, mode, id)</function>
  25. </title>
  26. <para>
  27. This function register a new timer and/or returns the internal ID
  28. associated with the timer. mode controls the creation of new timer
  29. if not found. id is to be used by start and log timer functions.
  30. </para>
  31. </section>
  32. <section>
  33. <title>
  34. <function moreinfo="none">bm_start(id)</function>
  35. </title>
  36. <para>
  37. This function equals the user-exported function bm_start_timer. The
  38. id is passed as an integer, though.
  39. </para>
  40. </section>
  41. <section>
  42. <title>
  43. <function moreinfo="none">bm_log(id)</function>
  44. </title>
  45. <para>
  46. This function equals the user-exported function bm_log_timer. The id
  47. is passed as an integer, though.
  48. </para>
  49. </section>
  50. </section>
  51. <section>
  52. <title>Benchmark API Example</title>
  53. <example>
  54. <title>Using the benchmark module's API from another module</title>
  55. <programlisting format="linespecific">
  56. ...
  57. #include "../benchmark/benchmark.h"
  58. ...
  59. struct bm_binds bmb;
  60. ...
  61. ...
  62. /* load the benchmarking API */
  63. if (load_bm_api( &amp;bmb )!=0) {
  64. LM_ERR("can't load benchmark API\n");
  65. goto error;
  66. }
  67. ...
  68. ...
  69. /* Start/log timers during a (usually user-exported) module function */
  70. bmp.bm_register("test", 1, &amp;id)
  71. bmb.bm_start(id);
  72. do_something();
  73. bmb.bm_log(id);
  74. ...
  75. </programlisting>
  76. </example>
  77. </section>
  78. </chapter>