Created
December 17, 2018 14:14
-
-
Save ganadist/f7f8a4a9f9bbf0ea62630dae28a060db to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
import os | |
import resource | |
import time | |
N_CPU = os.sysconf('SC_NPROCESSORS_ONLN') | |
class Usage: | |
def __init__(self): | |
self.start_time = 0 | |
def __enter__(self, *args): | |
print(args) | |
self.res_start = resource.getrusage(resource.RUSAGE_CHILDREN) | |
self.start_time = time.time() | |
def __exit__(self, *args): | |
duration = time.time() - self.start_time | |
res_end = resource.getrusage(resource.RUSAGE_CHILDREN) | |
stime = res_end.ru_stime - self.res_start.ru_stime | |
utime = res_end.ru_utime - self.res_start.ru_utime | |
idle = duration - (stime + utime) / N_CPU | |
print( | |
f'user = {utime} stime = {stime} total = {duration} idle = {idle}') | |
if __name__ == '__main__': | |
count = 10 | |
dirs = list(map(lambda x: str(x), range(count))) | |
os.system(f'rm -rf {" ".join(dirs)}') | |
with Usage(): | |
for i in dirs: | |
os.system( | |
f'git clone https://github.com/ganadist/AndroidPlatformBuilder {i}') | |
os.system(f'rm -rf {" ".join(dirs)}') | |
with Usage(): | |
for i in dirs: | |
os.system( | |
f'git clone ssh://github.com/ganadist/AndroidPlatformBuilder {i}') | |
os.system(f'rm -rf {" ".join(dirs)}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
git clone https://blahblah x 10 : user = 0.477663 stime = 0.20673899999999998 total = 14.000959157943726 idle = 13.915408907943725
git clone ssh://blahblah x 10 : user = 0.445813 stime = 0.16432599999999997 total = 34.26047897338867 idle = 34.18421159838867