-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1232: add Mark Adler's crc32c to speed things up using sse 4.2 CPU i…
…nstructions git-svn-id: https://xpra.org/svn/Xpra/trunk@13402 3bb7dfac-3a0b-4e04-842a-767bc560f471
- Loading branch information
Showing
6 changed files
with
417 additions
and
6 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
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,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() |
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,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() |
Oops, something went wrong.