Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
内存分配压力测试程序
# requirements: sudo apt-get install memtester
import sys
import os
def main():
if len(sys.argv) != 2 and len(sys.argv) !=3:
sys.exit("Usuage: %s <memory> [iterations]" % (sys.argv[0]))
if len(sys.argv) == 3:
iteration = int(sys.argv[2])
else:
iteration = 0
memory = sys.argv[1]
ret = os.system("sudo memtester %s %d" % (memory, iteration))
if ret == 0:
sys.exit("Successed!")
if ret & 0x1 == 0x1:
print("error allocatinh or locking memory, or inrocation error")
if ret & 0x2 == 0x2:
print("error during stuck address test")
if ret & 0x4 == 0x4:
print("error during one of the other tests")
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.