Skip to content

Commit

Permalink
hide performance results by default
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@13979 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 3, 2016
1 parent 3744e9f commit fc78ae3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/unittests/unit/server/motion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
import time
from zlib import crc32

from xpra.util import envbool
try:
from xpra.server.window import motion
except ImportError:
motion = None


SHOW_PERF = envbool("XPRA_SHOW_PERF")


class TestMotion(unittest.TestCase):

def test_match_distance(self):
Expand Down Expand Up @@ -93,7 +97,8 @@ def cdf(v1, v2):
array2 = [N*2-x*2 for x in range(N)]
d = motion.calculate_distances(array1, array2, 1)
end = time.time()
print("calculate_distances %4i^2 in %5.1f ms" % (N, (end-start)*1000))
if SHOW_PERF:
print("calculate_distances %4i^2 in %5.1f ms" % (N, (end-start)*1000))

def test_detect_motion(self):
W, H, BPP = 1920, 1080, 4
Expand Down Expand Up @@ -128,12 +133,14 @@ def tobytes(a):
start = time.time()
ov2 = motion.CRC_Image(buf2, W, H, W*BPP, BPP)
end = time.time()
print("\nCRC_Image %ix%i (%.1fMB) in %4.2f ms" % (W, H, len(buf2)//1024//1024, 1000.0*(end-start)))
if SHOW_PERF:
print("\nCRC_Image %ix%i (%.1fMB) in %4.2f ms" % (W, H, len(buf2)//1024//1024, 1000.0*(end-start)))
assert len(ov2)==H
start = time.time()
distances = motion.calculate_distances(ov1, ov2, min_score=1)
end = time.time()
print("calculate_distances %4i^2 in %5.2f ms" % (H, 1000.0*(end-start)))
if SHOW_PERF:
print("calculate_distances %4i^2 in %5.2f ms" % (H, 1000.0*(end-start)))
linecount = distances.get(N, 0)
assert linecount>0, "could not find distance %i" % N
assert linecount == (H-N), "expected to match %i lines but got %i" % (H-N, linecount)
Expand Down

0 comments on commit fc78ae3

Please sign in to comment.