forked from stratosphereips/StratosphereLinuxIPS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14b54f4
commit d528a69
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |