Skip to content

Commit

Permalink
* minor optimizations
Browse files Browse the repository at this point in the history
* log CRC_Image performance during unit tests

git-svn-id: https://xpra.org/svn/Xpra/trunk@13433 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 23, 2016
1 parent c25a805 commit 612c6cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/tests/unit/server/motion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ def test_detect_motion(self):
for N in (1, 20, 100):
na2 = np.roll(na1, -N*W*BPP//8)
buf2 = na2.tobytes()
start = time.time()
ov2 = motion.CRC_Image(buf2, W, H, W*BPP, BPP)
end = time.time()
print("CRC_Image %ix%i (%.1fMB) in %.1fms" % (W, H, len(buf2)//1024//1024, 1000.0*(end-start)))
assert len(ov2)==H
distances = motion.calculate_distances(ov1, ov2, min_score=1)
linecount = distances.get(N, 0)
Expand Down
6 changes: 3 additions & 3 deletions src/xpra/server/window/motion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def CRC_Image(pixels, unsigned int width, unsigned int height, unsigned int rows
DEF MAXINT64 = 2**63
DEF MAXUINT64 = 2**64
DEF MASK64 = 2**64-1
cdef castint64(v):
cdef inline castint64(v):
if v>=MAXINT64:
return v-MAXUINT64
#assert v>=0, "invalid int to cast: %s" % v
Expand Down Expand Up @@ -97,8 +97,8 @@ def calculate_distances(array1, array2, int min_score=0, int max_distance=1000):
maxy = min(l, y1+max_distance)
for y2 in range(miny, maxy):
if a1[y1]==a2[y2]:
d = y1-y2
distances[l+d] += 1
#distance = y1-y2
distances[l+y1-y2] += 1
r = {}
for i in range(2*l):
d = distances[i]
Expand Down

0 comments on commit 612c6cf

Please sign in to comment.