large_microbench.c 709 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "test/jemalloc_test.h"
  2. #include "test/bench.h"
  3. static void
  4. large_mallocx_free(void) {
  5. /*
  6. * We go a bit larger than the large minclass on its own to better
  7. * expose costs from things like zeroing.
  8. */
  9. void *p = mallocx(SC_LARGE_MINCLASS, MALLOCX_TCACHE_NONE);
  10. assert_ptr_not_null(p, "mallocx shouldn't fail");
  11. free(p);
  12. }
  13. static void
  14. small_mallocx_free(void) {
  15. void *p = mallocx(16, 0);
  16. assert_ptr_not_null(p, "mallocx shouldn't fail");
  17. free(p);
  18. }
  19. TEST_BEGIN(test_large_vs_small) {
  20. compare_funcs(100*1000, 1*1000*1000, "large mallocx",
  21. large_mallocx_free, "small mallocx", small_mallocx_free);
  22. }
  23. TEST_END
  24. int
  25. main(void) {
  26. return test_no_reentrancy(
  27. test_large_vs_small);
  28. }