Skip to content

Instantly share code, notes, and snippets.

@YoungForest
Created January 14, 2017 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YoungForest/73875763467c9cd1eeccad3496a18398 to your computer and use it in GitHub Desktop.
Save YoungForest/73875763467c9cd1eeccad3496a18398 to your computer and use it in GitHub Desktop.
内存分配压力测试程序
# 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