Created
January 14, 2017 11:22
-
-
Save YoungForest/73875763467c9cd1eeccad3496a18398 to your computer and use it in GitHub Desktop.
内存分配压力测试程序
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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