App/script to simulate memory write

Man of Honour
Joined
20 Sep 2006
Posts
35,408
Hi, I'm looking for an app or script which writes to memory pages, and if possible one which can define how much I'm writing. For example, script starts and it writes X GB/s to memory. Does such a thing exist? Preferably Ubuntu but can use most distros. Thanks!
 
Stress seems okay so far, the only thing I'd like is not to consume a whole CPU which it looks to do, but it's great for generating memory writes.

Code:
stress --vm 1 --vm-bytes 1024M --timeout 60

Will stress 1024 MB of RAM on a single thread over a minute.
 
I copied your post to CoPilot and it gave me this :)

Code:
import time

def write_to_memory(size_in_gb, duration_in_sec):
    data = bytearray(1024 * 1024 * 1024)  # 1 GB
    start_time = time.time()

    while time.time() - start_time < duration_in_sec:
        for _ in range(size_in_gb):
            _ = data  # Write data to memory

write_to_memory(1, 10)  # Write 1 GB/s to memory for 10 seconds
 
I copied your post to CoPilot and it gave me this :)

Code:
import time

def write_to_memory(size_in_gb, duration_in_sec):
    data = bytearray(1024 * 1024 * 1024)  # 1 GB
    start_time = time.time()

    while time.time() - start_time < duration_in_sec:
        for _ in range(size_in_gb):
            _ = data  # Write data to memory

write_to_memory(1, 10)  # Write 1 GB/s to memory for 10 seconds
So you've taken a simple one line command and made it complicated! :cry:
 
Back
Top Bottom