Ejemplo n.º 1
0
 def test_deep(self, iteration=None):
     key = self.KEY + ("deep", )
     item = self.deep_samples[iteration % len(self.deep_samples)]
     self._reset_buffer()
     with timed() as t:
         aioxmpp.xml.write_single_xso(item, self.buf)
     record(key + ("sz", ), self.buf.tell(), "B")
     record(key + ("rate", ), self.buf.tell() / t.elapsed, "B/s")
Ejemplo n.º 2
0
 def test_shallow_and_large(self):
     key = self.KEY + ("shallow+large",)
     item = ShallowRoot(scale=100)
     self._reset_buffer()
     with timed() as t:
         aioxmpp.xml.write_single_xso(item, self.buf)
     record(key+("sz",), self.buf.tell(), "B")
     record(key+("rate",), self.buf.tell() / t.elapsed, "B/s")
Ejemplo n.º 3
0
 def test_shallow_and_large(self):
     key = self.KEY + ("shallow+large", )
     item = ShallowRoot(scale=100)
     self._reset_buffer()
     with timed() as t:
         aioxmpp.xml.write_single_xso(item, self.buf)
     record(key + ("sz", ), self.buf.tell(), "B")
     record(key + ("rate", ), self.buf.tell() / t.elapsed, "B/s")
Ejemplo n.º 4
0
 def test_deep(self, iteration=None):
     key = self.KEY + ("deep",)
     item = self.deep_samples[iteration % len(self.deep_samples)]
     self._reset_buffer()
     with timed() as t:
         aioxmpp.xml.write_single_xso(item, self.buf)
     record(key+("sz",), self.buf.tell(), "B")
     record(key+("rate",), self.buf.tell() / t.elapsed, "B/s")
Ejemplo n.º 5
0
 def setUpClass(cls):
     rng = random.Random(1)
     cls.deep_samples = [
         DeepRoot()
         for i in range(10)
     ]
     for sample in cls.deep_samples:
         with timed(cls.KEY+("deep", "generate")):
             sample.generate(rng)
Ejemplo n.º 6
0
    def test_exhaustive_dualchar(self):
        validate = aioxmpp.xml.xmlValidateNameValue_str

        strs = ["x" + chr(cp) for cp in range(0, 0xd800)]

        with timed() as timer:
            for s in strs:
                validate(s)

        record(self.KEY + ("exhaustive_dualchar",),
               timer.elapsed / (len(strs)),
               "s")
Ejemplo n.º 7
0
    def test_random_strings(self):
        key = self.KEY + ("random",)

        validate = aioxmpp.xml.xmlValidateNameValue_str

        rng = random.Random(1)
        samples = []
        for i in range(1000):
            samples.append(base64.b64encode(
                random.getrandbits(120).to_bytes(120//8, 'little')
            ).decode("ascii").rstrip("="))

        for sample in samples:
            with timed() as timer:
                validate(sample)
            record(key, timer.elapsed, "s")
Ejemplo n.º 8
0
    def test_inserts(self):
        key = self.KEY + ("inserts", )

        N = 1000

        lru_dict = aioxmpp.cache.LRUDict()
        lru_dict.maxsize = N
        keys = [object() for i in range(N)]
        for i in range(N):
            lru_dict[keys[i]] = object()

        with timed() as t:
            for i in range(N):
                lru_dict[object()] = object()

        record(key, t.elapsed, "s")
Ejemplo n.º 9
0
    def test_random_access(self):
        key = self.KEY + ("random_access", )

        N = 1000

        lru_dict = aioxmpp.cache.LRUDict()
        lru_dict.maxsize = N
        keys = [object() for i in range(N)]
        for i in range(N):
            lru_dict[keys[i]] = object()

        with timed() as t:
            for i in range(N):
                lru_dict[keys[random.randrange(0, N)]]

        record(key, t.elapsed, "s")
Ejemplo n.º 10
0
    def test_inserts(self):
        key = self.KEY + ("inserts",)

        N = 1000

        lru_dict = aioxmpp.cache.LRUDict()
        lru_dict.maxsize = N
        keys = [object() for i in range(N)]
        for i in range(N):
            lru_dict[keys[i]] = object()

        with timed() as t:
            for i in range(N):
                lru_dict[object()] = object()

        record(key, t.elapsed, "s")
Ejemplo n.º 11
0
    def test_random_access(self):
        key = self.KEY + ("random_access",)

        N = 1000

        lru_dict = aioxmpp.cache.LRUDict()
        lru_dict.maxsize = N
        keys = [object() for i in range(N)]
        for i in range(N):
            lru_dict[keys[i]] = object()

        with timed() as t:
            for i in range(N):
                lru_dict[keys[random.randrange(0, N)]]

        record(key, t.elapsed, "s")
Ejemplo n.º 12
0
    def test_exhaustive(self):
        validate = aioxmpp.xml.xmlValidateNameValue_str

        r1 = range(0, 0xd800)
        r2 = range(0xe000, 0xf0000)

        range_iter = itertools.chain(
            # exclude surrogates
            r1, r2,
        )

        with timed() as timer:
            for cp in range_iter:
                validate(chr(cp))

        record(self.KEY + ("exhaustive",),
               timer.elapsed / (len(r1) + len(r2)),
               "s")