From 68663744b6a1004767e3368f3095c417411f1c90 Mon Sep 17 00:00:00 2001 From: Hariharan Devarajan Date: Thu, 10 Aug 2023 13:02:49 -0600 Subject: [PATCH] Update README.md --- README.md | 57 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 6ec0045d..85a65c96 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,11 @@ Requirements 1. Python > 3.8 2. spack -Install dependencies +Using spack dlio-profiler ``` -git clone git@github.com:hariharan-devarajan/dlio-profiler.git -cd dlio-profiler -spack env activater -p ./dependency +spack env create -d ./spack-env +spack env activate -p ./spack-env +spack add py-dlio-profiler@0.0.1 spack install ``` @@ -42,22 +42,53 @@ Usage import dlio_profiler_py as logger from time import sleep import os + cwd = os.getcwd() + + def custom_events(): - logger.start("test", "cat2") + args = { + "epoch": 1, + "index": 1, + } + start = logger.get_time() sleep(2) - logger.stop() + end = logger.get_time() + logger.log_event("test", "cat2", start, end - start, int_args=args) + -def posix_calls1(): - f = open(f"{cwd}/data/demofile2.txt", "w+") +def posix_calls1(index): + path=f"{cwd}/data/demofile{index}.txt" + f = open(path, "w+") f.write("Now the file has more content!") f.close() -def posix_calls2(): - f = open(f"{cwd}/data/demofile2.txt", "r") - data = f.read() - f.close() +import numpy as np + +def posix_calls2(index): + #print(f"{cwd}/data/demofile2.npz") + path = f"{cwd}/data/demofile{index}.npz" + if os.path.exists(path): + os.remove(path) + records = np.random.randint(255, size=(8, 8, 1024), dtype=np.uint8) + record_labels = [0] * 1024 + np.savez(path, x=records, y=record_labels) + +import threading -posix_calls1() +logger.initialize(f"{cwd}/log.pwf", f"{cwd}/data") +t1 = threading.Thread(target=posix_calls1, args=(10,)) custom_events() +t2 = threading.Thread(target=posix_calls2, args=(1,)) +t3 = threading.Thread(target=posix_calls2, args=(2,)) +# starting thread 1 +t1.start() +t2.start() +t3.start() + +t1.join() +t2.join() +t3.join() + +logger.finalize() ```