From f9e79cd73ce751aaa8773f92baf573c83485c78d Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 7 Nov 2019 20:38:27 +0300 Subject: [PATCH] tools: fast.v for fast.vlang.io --- tools/fast/fast.v | 68 ++++++++++++++++++++++++++++++++++++++++++ tools/fast/header.html | 34 +++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 tools/fast/fast.v create mode 100644 tools/fast/header.html diff --git a/tools/fast/fast.v b/tools/fast/fast.v new file mode 100644 index 0000000000..977311a684 --- /dev/null +++ b/tools/fast/fast.v @@ -0,0 +1,68 @@ +// Copyright (c) 2019 Alexander Medvednikov. All rights reserved. +// Use of this source code is governed by an MIT license +// that can be found in the LICENSE file. + +import os +import time + +fn main() { + exe := os.executable() + dir := os.dir(exe) + vdir := os.dir(dir) + if !os.file_exists('$vdir/v') && !os.dir_exists('$vdir/vlib') { + println('fast.html generator needs to be located in `v/tools/`') + } + println('fast.html generator\n') + // Fetch the last commit's hash + mut commit_hash := exec('git rev-parse HEAD') + commit_hash = commit_hash[..7] + mut table := os.read_file('table.html') or { '' } + // Do nothing if it's already been processed. + if table.contains(commit_hash) { + println('Commit $commit_hash has already been processed') + return + } + // Build an optimized V + println('Building vprod...') + exec('v -o $vdir/vprod -prod $vdir/v.v') + cmd := '$vdir/vprod -o v.c $vdir/v.v' + println('Warming up...') + for i in 0..3 { + os.exec(cmd) or { panic(err) } + } + println('Building...') + ticks := time.ticks() + os.exec(cmd) or { panic(err) } + diff := time.ticks() - ticks + println('Building V took ${diff}ms') + commit_date := exec('git log -n1 --pretty="format:%at"') + message := exec('git log -n1 --pretty="format:%s"') + date := time.unix(commit_date.int()) + out := os.create('table.html') or { panic(err) } + // Place the new row on top + table = +' + ${date.format()} + $commit_hash + $message + ${diff}ms + ${diff}ms + ${diff}ms +\n' + + table.trim_space() + out.writeln(table) + out.close() + // Regenerate index.html + header := os.read_file('header.html') or { panic(err) } + res := os.create('index.html') or { panic(err) } + res.writeln(header) + res.writeln(table) + res.close() +} + +fn exec(s string) string { + e := os.exec(s) or { panic(err) } + return e.output +} + + diff --git a/tools/fast/header.html b/tools/fast/header.html new file mode 100644 index 0000000000..5518555f84 --- /dev/null +++ b/tools/fast/header.html @@ -0,0 +1,34 @@ + + +fast.vlang.io + + + +

Is V still fast?

+ +Monitoring the speed of the compilation for each commit.

+ +Running on a $3.5/mo micro instance.

+Source code: fast.v

+ + + + + + + + + + +
Commit messagev -o v.cv -o vv -o v -fast