aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2020-08-13 16:40:48 +0100
committerYann Herklotz <git@yannherklotz.com>2020-08-13 16:41:47 +0100
commit8e0838b04a76f64342b570e22a1c0447c85ecd64 (patch)
tree4619aa015a17e63cab6818f609e91996d79a7eb9 /scripts
parent2246b834c3495de57795e514310d38905b890576 (diff)
downloadvericert-8e0838b04a76f64342b570e22a1c0447c85ecd64.tar.gz
vericert-8e0838b04a76f64342b570e22a1c0447c85ecd64.zip
Add statistics to be tracked
Diffstat (limited to 'scripts')
-rw-r--r--scripts/statistics.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/scripts/statistics.py b/scripts/statistics.py
index f3db9ff..7ff89ac 100644
--- a/scripts/statistics.py
+++ b/scripts/statistics.py
@@ -1,6 +1,8 @@
-import urllib.request
+import datetime
+import re
import subprocess
import sys
+import urllib.request
def collect(d):
@@ -17,7 +19,17 @@ def collect(d):
["grep", "-r", "-E", "Qed|Defined", d]).splitlines())
except: n_qed = 0
- return (n_admitted, n_theorems, n_qed)
+ try: n_files = len(subprocess.check_output(["find", d, "-name", "*.v"]).splitlines())
+ except: n_files = 0
+
+ try:
+ ps = subprocess.Popen(["find", d, "-name", "*.v"], stdout=subprocess.PIPE)
+ output = subprocess.check_output(["xargs", "wc"], stdin=ps.stdout).decode("utf-8").splitlines()[-1]
+ ps.wait()
+ n_lines = int(re.match("\s*(\d+)", output).group().strip())
+ except: n_lines = 0
+
+ return (n_files, n_lines, n_admitted, n_theorems, n_qed)
def pick_colour(n, m):
@@ -28,7 +40,7 @@ def pick_colour(n, m):
def main(d):
- n_admitted, n_theorems, _ = collect(d)
+ n_files, n_lines, n_admitted, n_theorems, n_qed = collect(d)
colour = pick_colour(n_admitted, n_theorems)
url = "https://img.shields.io/badge/admitted%20proofs-{}-{}?style=flat".format(
@@ -39,6 +51,11 @@ def main(d):
with urllib.request.urlopen(req) as r:
f.write(r.read())
+ with open(str(datetime.datetime.now()).replace(" ", "_")+".csv", "w") as f:
+ f.write("n_files,n_lines,n_admitted,n_theorems,n_qed\n"
+ +str(n_files)+","+str(n_lines)+","
+ +str(n_admitted)+","+str(n_theorems)+","+str(n_qed)+"\n")
+
if __name__ == "__main__":
main(sys.argv[1])