bst-vs-heap-vs-hashmap-gem5-stats 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env python3
  2. import common
  3. class Main(common.LkmcCliFunction):
  4. def __init__(self):
  5. super().__init__(
  6. defaults={
  7. 'emulator': 'gem5',
  8. 'show_time': False,
  9. },
  10. description='''\
  11. Convert a BST vs heap stat file into a gnuplot input
  12. https://cirosantilli.com/linux-kernel-module-cheat#bst-vs-heap-vs-hashmap
  13. ''',
  14. )
  15. def timed_main(self):
  16. stats = self.get_stats()
  17. it = iter(stats)
  18. i = 1
  19. for heap_num_cycles in it:
  20. try:
  21. bst_num_cycles = next(it)
  22. hashmap_num_cycles = next(it)
  23. except StopIteration:
  24. # Automatic dumpstats at end may lead to one extra stat at the end.
  25. break
  26. print('{} {} {} {}'.format(
  27. i,
  28. heap_num_cycles,
  29. bst_num_cycles,
  30. hashmap_num_cycles,
  31. ))
  32. i += 1
  33. if __name__ == '__main__':
  34. Main().cli()