-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# ADD COPYRIGHT HERE | ||
|
||
import os | ||
import sys | ||
import unittest | ||
import FreeCAD as App | ||
import Part | ||
|
||
try: | ||
from guppy import hpy | ||
|
||
Memtest = True | ||
except: | ||
Memtest = False | ||
|
||
try: | ||
import cProfile | ||
|
||
Pyprofile = True | ||
except: | ||
Pyprofile = False | ||
|
||
|
||
class PerfTestCase(unittest.TestCase): | ||
""" | ||
Test Case to test python syntax of all python files in FreeCAD | ||
""" | ||
|
||
def setUp(self): | ||
start = -1 | ||
for index in range(0, 20): | ||
if sys.argv[index] == "--pass": | ||
start = index + 1 | ||
break | ||
print("Setup", index, sys.argv) | ||
if start != -1: | ||
self.fileList = sys.argv[start:] | ||
if Part.Shape().ElementMapVersion == "": | ||
self.tnp = "" | ||
else: | ||
self.tnp = ".tnp" | ||
if Memtest: | ||
self.memfile = open(self.fileList[0] + self.tnp + ".mprofile", "w") | ||
Check warning on line 43 in src/Mod/Test/TestPerf.py GitHub Actions / Lint / Lint
|
||
|
||
def testAll(self): | ||
if Pyprofile: | ||
pr = cProfile.Profile() | ||
pr.enable() | ||
start = sys.activate_stack_trampoline | ||
start("perf") # avoid strange IDE syntax highlight error. | ||
for fileName in self.fileList: | ||
doc = App.openDocument(fileName) | ||
doc.recompute() # The heart of the performance measurement. | ||
if Memtest: | ||
dumpdata = hpy().heap() | ||
dumpdata.stat.dump(self.memfile) | ||
self.memfile.flush() | ||
App.closeDocument(doc.Name) | ||
sys.deactivate_stack_trampoline() | ||
if Pyprofile: | ||
pr.disable() | ||
pr.dump_stats(self.fileList[0] + self.tnp + ".cprofile") | ||
if Memtest: | ||
self.memfile.close() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#! /bin/bash | ||
|
||
# --no-buffering | ||
perf record -o $1.perf /home/brad/git/FreeCADtoponaming/build/bin/FreeCADCmd -t TestPerf --pass $@ | ||
|
||
# For interactive walking of the details: | ||
#perf report -i $1.perf | ||
|
||
# Output a total time in seconds to execute the document load and recompute | ||
times=($(perf script -F time -i $1.perf | sed -e's/://' -e'1p;$!d')) # Grab the first and last line timestamps | ||
totaltime=$(echo ${times[1]} - ${times[0]} | bc) | ||
echo $totaltime | ||
|