Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_mem_usage.c 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (c) 2012, Chris Andrews. All rights reserved.
  3. */
  4. #include "usdt.h"
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. static void
  9. create_and_free_provider(int argc, char **argv)
  10. {
  11. usdt_provider_t *provider;
  12. usdt_probedef_t *probedef;
  13. if ((provider = usdt_create_provider("testlibusdt", "modname")) == NULL) {
  14. fprintf(stderr, "unable to create provider\n");
  15. exit (1);
  16. }
  17. if ((probedef = usdt_create_probe((const char *)argv[1],
  18. (const char *)argv[2],
  19. (argc-3), (const char **)&argv[3])) == NULL)
  20. {
  21. fprintf(stderr, "unable to create probe\n");
  22. exit (1);
  23. }
  24. usdt_provider_add_probe(provider, probedef);
  25. if ((usdt_provider_enable(provider)) < 0) {
  26. fprintf(stderr, "unable to enable provider: %s\n", usdt_errstr(provider));
  27. exit (1);
  28. }
  29. if ((usdt_provider_disable(provider)) < 0) {
  30. fprintf(stderr, "unable to disable provider: %s\n", usdt_errstr(provider));
  31. exit (1);
  32. }
  33. usdt_probe_release(probedef);
  34. usdt_provider_free(provider);
  35. }
  36. int
  37. main(int argc, char **argv)
  38. {
  39. char char_argv[USDT_ARG_MAX];
  40. int int_argv[USDT_ARG_MAX * 2];
  41. int i;
  42. char buf[255];
  43. for (i = 0; i < USDT_ARG_MAX; i++)
  44. int_argv[i] = i + 1;
  45. for (i = 0; i < USDT_ARG_MAX; i++)
  46. char_argv[i] = (char) i + 65;
  47. if (argc < 3) {
  48. fprintf(stderr, "usage: %s func name [types ...]\n", argv[0]);
  49. return(1);
  50. }
  51. for (i = 0; i < USDT_ARG_MAX; i++) {
  52. if (argv[i+3] != NULL && i+3 < argc) {
  53. if (strncmp("c", argv[i+3], 1) == 0) {
  54. argv[i+3] = strdup("char *");
  55. }
  56. if (strncmp("i", argv[i+3], 1) == 0) {
  57. argv[i+3] = strdup("int");
  58. }
  59. }
  60. }
  61. for (i = 0; i < 100000; i++)
  62. create_and_free_provider(argc, argv);
  63. return 0;
  64. }