Last change
on this file was e0350e0, checked in by Michael Brooks <mlbrooks@…>, 4 months ago |
Recent rework of string benchmarks
|
-
Property mode
set to
100644
|
File size:
944 bytes
|
Rev | Line | |
---|
[e0350e0] | 1 | #!/usr/bin/env python3
|
---|
| 2 | import sys
|
---|
| 3 | import math
|
---|
| 4 |
|
---|
| 5 | def main():
|
---|
| 6 | if len(sys.argv) != 4:
|
---|
| 7 | print("Usage: script.py <start> <end> <ptsPerDouble>", file=sys.stderr)
|
---|
| 8 | sys.exit(1)
|
---|
| 9 |
|
---|
| 10 | try:
|
---|
| 11 | start = int(sys.argv[1])
|
---|
| 12 | end = int(sys.argv[2])
|
---|
| 13 | ptsPerDouble = float(sys.argv[3])
|
---|
| 14 | except ValueError:
|
---|
| 15 | print("Error: start and end must be integers; ptsPerDouble must be a float.", file=sys.stderr)
|
---|
| 16 | sys.exit(1)
|
---|
| 17 |
|
---|
| 18 | if start <= 0 or end <= start or ptsPerDouble <= 0:
|
---|
| 19 | print("Error: Ensure start > 0, end > start, ptsPerDouble > 0", file=sys.stderr)
|
---|
| 20 | sys.exit(1)
|
---|
| 21 |
|
---|
| 22 | values = []
|
---|
| 23 | i = 0
|
---|
| 24 | last_val = None
|
---|
| 25 |
|
---|
| 26 | while True:
|
---|
| 27 | val = int(start * 2 ** (i / ptsPerDouble))
|
---|
| 28 | if val >= end:
|
---|
| 29 | break
|
---|
| 30 | if val != last_val:
|
---|
| 31 | values.append(str(val))
|
---|
| 32 | last_val = val
|
---|
| 33 | i += 1
|
---|
| 34 |
|
---|
| 35 | print(" ".join(values))
|
---|
| 36 |
|
---|
| 37 | if __name__ == "__main__":
|
---|
| 38 | main()
|
---|
Note:
See
TracBrowser
for help on using the repository browser.