Skip to content

Commit

Permalink
#1232: add Mark Adler's crc32c to speed things up using sse 4.2 CPU i…
Browse files Browse the repository at this point in the history
…nstructions

git-svn-id: https://xpra.org/svn/Xpra/trunk@13402 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 20, 2016
1 parent 21d6a81 commit 6929cde
Show file tree
Hide file tree
Showing 6 changed files with 417 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2178,9 +2178,13 @@ def osx_pkgconfig(*pkgs_options, **ekw):
cython_add(Extension("xpra.server.window.region",
["xpra/server/window/region.pyx"],
**O3_pkgconfig))
cython_add(Extension("xpra.server.window.motion",
["xpra/server/window/motion.pyx"]+membuffers_c,
**O3_pkgconfig))
#no pthreads on win32:
if not WIN32:
motion_pkgconfig = O3_pkgconfig.copy()
add_to_keywords(motion_pkgconfig, 'extra_link_args', "-lpthread")
cython_add(Extension("xpra.server.window.motion",
["xpra/server/window/motion.pyx"]+membuffers_c+["xpra/buffers/crc32c.c"],
**O3_pkgconfig))


toggle_packages(enc_proxy_ENABLED, "xpra.codecs.enc_proxy")
Expand Down
42 changes: 42 additions & 0 deletions src/tests/xpra/server/test_crc32c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python
# This file is part of Xpra.
# Copyright (C) 2016 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

import time
import numpy as np

from xpra.server.window.motion import CRC_Image


def test_CRC_Image():
start = time.time()
N = 100
W = 1920
H = 1080
BPP = 4
LEN = W * H * BPP
buf = np.random.randint(256, size=LEN).tobytes()
ov = CRC_Image(buf, W//4, H, W, 4)
#print("CRC_Image(..)=%s" % (ov, ))
for _ in range(N):
v = CRC_Image(buf, W//4, H, W, 4)
assert v==ov
assert len(v)==H
end = time.time()
elapsed = end-start
print("crc32c: %i times %ix%i (%.1fMB) in %.3fs, %.1fGB/s" % (N, W, H, LEN//(1024.0*1024.0), elapsed, ((N*LEN) / (end-start) / (1024*1024*1024))))
#just for comparing:
#crc the whole buffer (which is more advantageous)
from zlib import crc32
start = time.time()
v = crc32(buf)
end = time.time()
print("zlib.crc32: %.2fMB/s" % ((N*LEN)//(end-start)/(1024*1024*1024)))

def main():
test_CRC_Image()

if __name__ == "__main__":
main()
17 changes: 17 additions & 0 deletions src/tests/xpra/test_apps/test_window_iconify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python

import glib
import gtk

def main():
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_size_request(400, 200)
window.connect("delete_event", gtk.mainquit)
window.iconify()
glib.timeout_add(2000, window.deiconify)
gtk.main()
return 0


if __name__ == "__main__":
main()
Loading

0 comments on commit 6929cde

Please sign in to comment.