summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-05-02 13:41:36 +0200
committerChristian Poessinger <christian@poessinger.com>2020-05-02 13:41:36 +0200
commit51f98e74749acd4b41c642380c7ad4d340e9d3c2 (patch)
tree8639bc66938657631ca98b050536c5f671802ac8 /src
parent096c77340b2a6a72edbed660fe4fb000aca9275f (diff)
downloadvyos-1x-51f98e74749acd4b41c642380c7ad4d340e9d3c2.tar.gz
vyos-1x-51f98e74749acd4b41c642380c7ad4d340e9d3c2.zip
validators: numeric: T2414: improve runtime performance
$ time for i in {1..1000}; do /usr/libexec/vyos/validators/numeric --range 1-9999 666; done real 0m56.933s user 0m48.045s sys 0m9.064s $ time for i in {1..1000}; do /usr/libexec/vyos/validators/numeric--range 1-9999 666; done real 0m44.552s user 0m37.760s sys 0m6.989s This is a performance improvement of 21%, running in an ESXi VM with Quad Intel(R) Xeon(R) CPU E5-2630L v3 @ 1.80GHz.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/validators/numeric6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/validators/numeric b/src/validators/numeric
index 0a2d83d14..2cd5178b9 100755
--- a/src/validators/numeric
+++ b/src/validators/numeric
@@ -19,7 +19,6 @@
import sys
import argparse
-import re
parser = argparse.ArgumentParser()
parser.add_argument("-f", "--float", action="store_true", help="Accept floating point values")
@@ -50,8 +49,9 @@ if args.range:
valid = False
for r in args.range:
try:
- lower, upper = re.match(r'(\d+)\s*\-\s*(\d+)', r).groups()
- lower, upper = int(lower), int(upper)
+ list = r.split('-')
+ lower = int(list[0])
+ upper = int(list[1])
except:
print("{0} is not a valid number range",format(args.range), file=sys.stderr)
sys.exit(1)