ComputerTests 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- computertests-0.1.0/ComputerTests.egg-info/PKG-INFO +7 -0
- computertests-0.1.0/ComputerTests.egg-info/SOURCES.txt +7 -0
- computertests-0.1.0/ComputerTests.egg-info/dependency_links.txt +1 -0
- computertests-0.1.0/ComputerTests.egg-info/top_level.txt +1 -0
- computertests-0.1.0/PKG-INFO +7 -0
- computertests-0.1.0/README.md +1 -0
- computertests-0.1.0/capabilities.py +123 -0
- computertests-0.1.0/pyproject.toml +12 -0
- computertests-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
capabilities
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
My python import tests a computer capabilities, including RAM, CPU, and memory writing speeds.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import multiprocessing
|
|
2
|
+
import time as t
|
|
3
|
+
|
|
4
|
+
def ram(workers: int, RAM_chunk_size: int, timeDuration: int, repeat: bool):
|
|
5
|
+
RAM_chunk_size *= 1024 * 1024
|
|
6
|
+
if workers < 0: #negative number so optimum amount
|
|
7
|
+
workers = multiprocessing.cpu_count()
|
|
8
|
+
for i in range(1,workers+1):
|
|
9
|
+
work = multiprocessing.Process(target = ramWorker, args = (RAM_chunk_size,repeat,timeDuration))
|
|
10
|
+
work.start()
|
|
11
|
+
return True
|
|
12
|
+
|
|
13
|
+
def ramWorker(RAM_chunk_size, repeat, time):
|
|
14
|
+
ramHog = []
|
|
15
|
+
start = t.time()
|
|
16
|
+
while t.time() - start < time:
|
|
17
|
+
try:
|
|
18
|
+
ramHog.append(b"0" * RAM_chunk_size)
|
|
19
|
+
except MemoryError:
|
|
20
|
+
if repeat:
|
|
21
|
+
RAM_chunk_size //= 2
|
|
22
|
+
else:
|
|
23
|
+
return
|
|
24
|
+
if RAM_chunk_size < 100:
|
|
25
|
+
return
|
|
26
|
+
except Exception as error:
|
|
27
|
+
return
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# open many files
|
|
31
|
+
def files(numOfFiles: int, Name: str, size: int):
|
|
32
|
+
size *= 1024 * 1024
|
|
33
|
+
for i in range(1,numOfFiles+1):
|
|
34
|
+
work = multiprocessing.Process(target = openFile, args = (Name, i, size))
|
|
35
|
+
work.start()
|
|
36
|
+
def openFile(name, ID, size):
|
|
37
|
+
with open(f"{name}{ID}.txt","ab") as file:
|
|
38
|
+
file.write(b"0" * size)
|
|
39
|
+
return True
|
|
40
|
+
|
|
41
|
+
# open large files
|
|
42
|
+
def ssd(workers: int, chunk_size: int, name: str, timeDuration: int, repeat: bool):
|
|
43
|
+
chunk_size *= 1024 * 1024
|
|
44
|
+
if workers < 0: #negative number so optimum amount
|
|
45
|
+
workers = multiprocessing.cpu_count()
|
|
46
|
+
for i in range(1,workers+1):
|
|
47
|
+
work = multiprocessing.Process(target = ssdWorker, args = (i,chunk_size,name,repeat, timeDuration))
|
|
48
|
+
work.start()
|
|
49
|
+
return True
|
|
50
|
+
|
|
51
|
+
def ssdWorker(ID, size, name, repeat, time):
|
|
52
|
+
start = t.time()
|
|
53
|
+
if repeat:
|
|
54
|
+
with open(f"{name}{ID}.txt","ab") as file:
|
|
55
|
+
while t.time() - start < time:
|
|
56
|
+
try:
|
|
57
|
+
file.write(b"0" * size)
|
|
58
|
+
except MemoryError:
|
|
59
|
+
size //= 2
|
|
60
|
+
if size < 100:
|
|
61
|
+
return
|
|
62
|
+
else:
|
|
63
|
+
with open(f"{name}{ID}.txt","ab") as file:
|
|
64
|
+
try:
|
|
65
|
+
file.write(b"0" * size)
|
|
66
|
+
except MemoryError:
|
|
67
|
+
return
|
|
68
|
+
return
|
|
69
|
+
|
|
70
|
+
def cpu(workers: int, timeDuration: int, doMath: bool):
|
|
71
|
+
import random as r
|
|
72
|
+
if workers < 0:
|
|
73
|
+
workers = multiprocessing.cpu_count()
|
|
74
|
+
for i in range(0,workers):
|
|
75
|
+
work = multiprocessing.Process(target = cpuTest, args = (timeDuration, doMath))
|
|
76
|
+
work.start()
|
|
77
|
+
return True
|
|
78
|
+
|
|
79
|
+
def cpuTest(timeDuration, doMath):
|
|
80
|
+
start = t.time()
|
|
81
|
+
if doMath:
|
|
82
|
+
while t.time() - start < timeDuration:
|
|
83
|
+
thing = r.randint(1,99999) ** r.randint(1,99999)
|
|
84
|
+
else:
|
|
85
|
+
while t.time() - start < timeDuration:
|
|
86
|
+
pass
|
|
87
|
+
return
|
|
88
|
+
def info():
|
|
89
|
+
print("""
|
|
90
|
+
--- Computer testing import ---
|
|
91
|
+
Terms:
|
|
92
|
+
'worker' -> The number of threads to do the same task, spread across
|
|
93
|
+
different CPU cores.
|
|
94
|
+
'chunk_size' -> In MB, the size of each task to do e.g. create 50MB text files.
|
|
95
|
+
'repeat' -> Repeat task until recources are depleted. Use with caution.
|
|
96
|
+
'name' -> the name used to create text files. These are modified as such:
|
|
97
|
+
{given Argument}{incrementing number}.txt
|
|
98
|
+
Different file types are unsuported.
|
|
99
|
+
'timeDuration' -> How long in seconds to do a task. The time is decided to stop
|
|
100
|
+
after each successfull chunk.
|
|
101
|
+
'doMath' -> Stress the CPU core specifically with math if True, or without it.
|
|
102
|
+
Note that cpu() fully occupies its respective CPU core, and may be
|
|
103
|
+
harder to close the program if maxed out. Modern computing systems
|
|
104
|
+
do still allow mouse movements and inputs, but may stutter.
|
|
105
|
+
|
|
106
|
+
Function names:
|
|
107
|
+
ram(workers, chunk_size, timeDuration, repeat):
|
|
108
|
+
Fills RAM with specified arguments.
|
|
109
|
+
files(numberOfFiles, name, size):
|
|
110
|
+
Used for opening many files, not heavy files.
|
|
111
|
+
ssd(workers, chunk_size, name, timeDuration, repeat):
|
|
112
|
+
Used for heavy size file creations.
|
|
113
|
+
cpu(workers, timeDuration, doMath):
|
|
114
|
+
Stress a CPU, spread across CPU cores.
|
|
115
|
+
|
|
116
|
+
This module uses imports: multiprocessing, time, and random.
|
|
117
|
+
Each function returns True upon succession of starting the number of workers
|
|
118
|
+
Giving the functions a negative number in place of worker count, will instead be treated as the optimum amount.
|
|
119
|
+
The optimum amount is based on number of CPU cores.
|
|
120
|
+
|
|
121
|
+
YOU MUST have if __name__ == "__main__": main() in your program for this to work.
|
|
122
|
+
|
|
123
|
+
""")
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ComputerTests"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Computer capabilities testing "
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
|
|
11
|
+
[tool.setuptools]
|
|
12
|
+
py-modules = ["capabilities"]
|