Created
March 16, 2016 01:03
-
-
Save smerritt/4afb2198e23b390e18b8 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import benchmark | |
from swift.container.backend import ContainerBroker | |
class BenchmarkListingOperations(benchmark.Benchmark): | |
def setUp(self): | |
self.broker = ContainerBroker("big-container-db/big.db", | |
account='big-a', container='big-c') | |
oc = self.broker.get_info()['object_count'] | |
print "this container DB has %d object rows in it" % oc | |
def test_plain_list(self): | |
self.broker.list_objects_iter(limit=10000, marker='', end_marker=None, | |
prefix=None, delimiter=None) | |
def test_list_with_marker(self): | |
# Every object in here has a name of the form "object-<32 hex | |
# chars>", so "object-abcdef" is a decent enough marker. | |
self.broker.list_objects_iter(limit=10000, marker='object-abcdef', | |
end_marker=None, | |
prefix=None, delimiter=None) | |
def test_list_contains_finds_rows(self): | |
# Every object in here has a name of the form "object-<32 hex | |
# chars>", so "ab" will show up in enough of them that this can find | |
# 10,000 results without examining every row. | |
self.broker.list_objects_iter(limit=10000, marker='', end_marker=None, | |
prefix=None, delimiter=None, | |
contains="ab") | |
def test_list_contains_finds_nothing(self): | |
# Every object in here has a name of the form "object-<32 hex | |
# chars>", so "zz" isn't in there at all. | |
self.broker.list_objects_iter(limit=10000, marker='', end_marker=None, | |
prefix=None, delimiter=None, | |
contains="zz") | |
if __name__ == '__main__': | |
benchmark.main(each=3) |
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
swift@saio:~$ ./contains-query.py | |
this container DB has 43785182 object rows in it | |
Benchmark Report | |
================ | |
BenchmarkListingOperations | |
-------------------------- | |
name | rank | runs | mean | sd | timesBaseline | |
----------------------------|------|------|-------|-------|-------------- | |
plain list | 1 | 3 | 1.267 | 2.093 | 1.0 | |
list with marker | 2 | 3 | 2.905 | 2.482 | 2.29264480416 | |
list contains finds rows | 3 | 3 | 3.929 | 3.317 | 3.10083327698 | |
list contains finds nothing | 4 | 3 | 374.7 | 16.34 | 295.756425965 | |
Each of the above 12 runs were run in random, non-consecutive order by | |
`benchmark` v0.1.5 (http://jspi.es/benchmark) with Python 2.7.11 | |
Linux-3.16.0-57-generic-x86_64 on 2016-03-06 16:58:12. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment