File: test_joins.py

package info (click to toggle)
python-agate 1.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,996 kB
  • sloc: python: 8,512; makefile: 126
file content (29 lines) | stat: -rw-r--r-- 767 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import unittest
from random import shuffle
from timeit import Timer

import agate


class TestTableJoin(unittest.TestCase):
    def test_join(self):
        left_rows = [(str(i), i) for i in range(100000)]
        right_rows = [(str(i), i) for i in range(100000)]

        shuffle(left_rows)
        shuffle(right_rows)

        column_names = ['text', 'number']
        column_types = [agate.Text(), agate.Number()]

        left = agate.Table(left_rows, column_names, column_types)
        right = agate.Table(right_rows, column_names, column_types)

        def test():
            left.join(right, 'text')

        results = Timer(test).repeat(10, 1)

        min_time = min(results)

        self.assertLess(min_time, 20)  # CI unreliable, 15s witnessed on PyPy