Introduction
Introduction Statistics Contact Development Disclaimer Help
merge-benchmark-func.py - libzahl - big integer library
git clone git://git.suckless.org/libzahl
Log
Files
Refs
README
LICENSE
---
merge-benchmark-func.py (1500B)
---
1 #!/usr/bin/env python3
2 # See LICENSE file for copyright and license details.
3
4
5 # Invoke using `env SELECT_MIN=` to select the minimum value,
6 # rather than concatenate. This applies to 1-dimensional data only.
7
8
9 import sys, os
10
11 line_count = None
12 files = []
13
14 for path in sys.argv[1:]:
15 with open(path, 'rb') as file:
16 data = file.read()
17 data = data.decode('utf-8', 'strict')
18 if data[-1] == '\n':
19 data = data[:-1]
20 data = data.split('\n')
21 if line_count is None:
22 line_count = len(data)
23 elif len(data) != line_count:
24 print('%s: line count mismatch' % sys.argv[0], file = sys.stderr)
25 sys.exit(1)
26 files.append(data)
27
28 dim = int(files[0][1])
29 skip = 1 + dim
30 for i in range(skip):
31 print(files[0][i])
32
33 if dim > 1:
34 for i in range(skip, line_count):
35 best_nsec = None
36 best_line = None
37 for lines in files:
38 line = lines[i]
39 nsec = int(line)
40 if best_nsec is None or nsec < best_nsec:
41 best_nsec, best_line = nsec, line
42 print(best_line)
43 elif 'SELECT_MIN' not in os.environ:
44 for lines in files:
45 for i in range(skip, line_count):
46 print(lines[i])
47 else:
48 best_nsec = None
49 best_line = None
50 for lines in files:
51 for i in range(skip, line_count):
52 line = lines[i]
53 nsec = int(line)
54 if best_nsec is None or nsec < best_nsec:
55 best_nsec, best_line = nsec, line
56 print(best_line)
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.