Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. # this made for python3
  3.  
  4. import os
  5. import subprocess as sp
  6.  
  7. class RunTest:
  8. """ """
  9. DEBUG = False
  10. MAXTry = 100
  11.  
  12. def do(self):
  13. structDic = eval("{" + self.doStructLoop() + "}")
  14. for x in range(0, self.MAXTry):
  15. self.mapReduce(structDic, "{" + self.doStructLoop() + "}")
  16. self.printResult("StructTrials", structDic)
  17.  
  18. def doStructLoop(self):
  19. return sp.check_output("./aStruct.out", shell=True, universal_newlines=True)
  20.  
  21. def mapReduce(self, baseDic, dicStr):
  22. newDic = eval(dicStr)
  23. self.DebugPrint(newDic)
  24. for key, val in newDic.items():
  25. baseDic[key] += val
  26.  
  27. def printResult(self, signiture, dic):
  28. print(signiture)
  29. for key, val in dic.items():
  30. print("%s : av = %f, total = %f" % (key, val/self.MAXTry, val))
  31.  
  32. @staticmethod
  33. def DebugPrint(str):
  34. if RunTest.DEBUG:
  35. print(str)
  36. else:
  37. pass
  38.  
  39.  
  40. if __name__ == "__main__":
  41. os.system('swiftc -sdk $(xcrun --show-sdk-path --sdk macosx) -o aStruct.out for-inExp-struct.swift')
  42. print("no Optimize")
  43. ins = RunTest()
  44. ins.do()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement