diff options
Diffstat (limited to 'trunk/scripts')
-rwxr-xr-x | trunk/scripts/checksum-benchmark | 23 | ||||
-rwxr-xr-x | trunk/scripts/list-gdkpixbuf-formats | 17 | ||||
-rwxr-xr-x | trunk/scripts/pyexiv2dump | 15 | ||||
-rwxr-xr-x | trunk/scripts/test-bgjobs | 47 |
4 files changed, 102 insertions, 0 deletions
diff --git a/trunk/scripts/checksum-benchmark b/trunk/scripts/checksum-benchmark new file mode 100755 index 0000000..5f70017 --- /dev/null +++ b/trunk/scripts/checksum-benchmark @@ -0,0 +1,23 @@ +#!/bin/sh +# +# Compare various checksum algorithms for speed. + +set -e + +algo() +{ + printf "%6s: " "$1" + python -m timeit \ + -c \ + -s 'import hashlib' \ + -s 'data = file("test-plugins/test.cr2").read()' \ + "hashlib.new('$1', string=data)" +} + +algo md5 +algo sha1 +algo sha224 +algo sha256 +algo sha384 +algo sha512 + diff --git a/trunk/scripts/list-gdkpixbuf-formats b/trunk/scripts/list-gdkpixbuf-formats new file mode 100755 index 0000000..d29b14b --- /dev/null +++ b/trunk/scripts/list-gdkpixbuf-formats @@ -0,0 +1,17 @@ +#!/usr/bin/python +# +# A small Python script to list the file formats GdkPixbuf supports. + + +import gtk + + +for format in gtk.gdk.pixbuf_get_formats(): + print '%s: ' % format['name'] + print ' description: %s' % format['description'] + print ' mime_types:' + for mime_type in format['mime_types']: + print ' %s' % mime_type + print ' extensions: %s' % ' '.join(format['extensions']) + print ' is writable: %s' % format['is_writable'] + print diff --git a/trunk/scripts/pyexiv2dump b/trunk/scripts/pyexiv2dump new file mode 100755 index 0000000..80ac8a1 --- /dev/null +++ b/trunk/scripts/pyexiv2dump @@ -0,0 +1,15 @@ +#!/usr/bin/python + +import sys + +import pyexiv2 + + +for filename in sys.argv[1:]: + image = pyexiv2.Image(filename) + image.readMetadata() + print filename + for key in image.exifKeys(): + print " %s: %s" % (key, repr(image[key])) + print " --> %s" % repr(image.interpretedExifValue(key)) + diff --git a/trunk/scripts/test-bgjobs b/trunk/scripts/test-bgjobs new file mode 100755 index 0000000..1526ca3 --- /dev/null +++ b/trunk/scripts/test-bgjobs @@ -0,0 +1,47 @@ +#!/usr/bin/python +# +# A small test script to excercise the bgjobs stuff. We create a number of +# jobs, and make run them, and make sure the results are correct. +# +# By running this script a large number of times (say, 10 000) in a loop, +# it may be possible to expose race conditions. (As of the time of committing, +# no such are known.) +# +# If you want to run this in the source directory, do this: +# +# PYTHONPATH=. python scripts/test-bgjobs + + +import Queue +import time + +import dimbola + + +N = 100000 + + +class SlowJob(dimbola.BackgroundJob): + + def __init__(self, value): + self.value = value + + def run(self): + return self.value + + +manager = dimbola.BackgroundManager() +for i in range(N): + manager.add_job(SlowJob(i)) +manager.start_jobs(maxproc=None) +results = 0 +while manager.running: + try: + result = manager.results.get(block=False) + except Queue.Empty: + pass + else: + results += 1 +manager.stop_jobs() +assert results == N, "results==%d (not %d)" % (results, N) + |