Skip to content

Commit

Permalink
first branch commit
Browse files Browse the repository at this point in the history
  • Loading branch information
danieltherealyang committed Jul 13, 2023
1 parent 14b54f4 commit d528a69
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
Binary file added memraytest/output.bin
Binary file not shown.
10 changes: 10 additions & 0 deletions memraytest/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import memray

def generate_large_list():
large_list = list(range(10_000_000)) # Create a list of 10 million integers
return large_list

memray_context = memray.Tracker("output.bin")
memray_context.__enter__()
generate_large_list()
memray_context.__exit__(None, None, None)
45 changes: 45 additions & 0 deletions slips_files/common/memory_profiler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import memray
from slips_files.common.abstracts import ProfilerInterface

class MemoryProfiler(ProfilerInterface):
profiler = None
def __init__(self, output, mode="dev"):
valid_modes = ["dev", "live"]
if mode not in valid_modes:
print("memory_profiler_mode = " + mode + " is invalid, must be one of " +
str(valid_modes) + ", Memory Profiling will be disabled")
if mode == "dev":
self.profiler = DevProfiler(output)

def _create_profiler(self):
self.profiler._create_profiler()

def start(self):
print("Memory Profiler Started")
self.profiler.start()

def stop(self):
self.profiler.stop()
print("Memory Profiler Ended")

def print(self):
pass

class DevProfiler(ProfilerInterface):
output = None
profiler = None
def __init__(self, output):
self.output = output
self.profiler = self._create_profiler()

def _create_profiler(self):
return memray.Tracker(self.output)

def start(self):
self.profiler.__enter__()

def stop(self):
self.profiler.__exit__(None, None, None)

def print(self):
pass

0 comments on commit d528a69

Please sign in to comment.