-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprocessing.py
37 lines (30 loc) · 1.03 KB
/
processing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import models
import os
import subprocess
import time
import random
from math import sqrt, e, pi
import numpy as np
import matplotlib.pyplot as plt
random_seed = 177
start_time = time.time()
sample_width = models.sample_width
random.seed(random_seed)
sigma = 2.5
def GetMemory():
if os.name == 'posix':
mem_info = subprocess.check_output(['free','-b']).decode().split()
total_memory = int(mem_info[7]) - int(mem_info[8])
total_memory *= 10**-9
elif os.name == 'nt':
mem_info = subprocess.check_output(['wmic','OS','get','FreePhysicalMemory']).decode().split()
total_memory = int(mem_info[1]) * 1024 * 10**-9
print(f"Available memory: {total_memory:0.2f} GB")
def GetTime():
seconds = int(time.time() - start_time)
hours = seconds // 3600
seconds = seconds % 3600
minutes = seconds // 60
seconds = seconds % 60
print(f"Total time elapsed: {hours}h {minutes}m {seconds}s")
Normal = lambda x, mean: e**(-0.5*((x-mean)/sigma)**2) / (sigma * sqrt(2*pi))