Created
March 26, 2015 15:11
-
-
Save lambdalisue/c73ad37a33b8242fba13 to your computer and use it in GitHub Desktop.
Benchmark Vital.VCS.Git.Finder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let s:V = vital#of('vital') | |
let s:G = s:V.import('VCS.Git.Core') | |
let s:F = s:V.import('VCS.Git.Finder') | |
function! s:test1(path, dummy) | |
let c = 1 | |
let args = ['rev-parse', '--is-inside-work-tree'] | |
let start = reltime() | |
while c < 100 | |
let result = s:G.exec(args, { 'cwd': a:path }) | |
if result.status || result.stdout !~# 'true' | |
throw "Fail" | |
endif | |
let c += 1 | |
endwhile | |
echomsg reltimestr(reltime(start)) | |
endfunction | |
function! s:test2(path, cache) | |
let c = 1 | |
let f = s:F.new(a:cache) | |
let start = reltime() | |
while c < 100 | |
if empty(f.find(a:path)) | |
throw "Fail" | |
endif | |
let c += 1 | |
endwhile | |
echomsg reltimestr(reltime(start)) | |
endfunction | |
function! Test(n, msg, cache) | |
echomsg "" | |
echomsg "Test" . string(a:n) . ": " . a:msg | |
echomsg "==================================================================" | |
let c = 1 | |
while c < 10 | |
call s:test{a:n}(expand("<sfile>"), a:cache) | |
let c += 1 | |
endwhile | |
echomsg "==================================================================" | |
endfunction | |
function! Tests() | |
call Test(1, "Via git rev-parse --is-inside-work-tree", {}) | |
call Test(2, "Via VCS.Git.Finder (with dummy cache)", s:V.import('System.Cache.Dummy').new()) | |
call Test(2, "Via VCS.Git.Finder (with file cache)", s:V.import('System.Cache.File').new('.cache' )) | |
call Test(2, "Via VCS.Git.Finder (with simple cache)", s:V.import('System.Cache.Simple').new()) | |
endfunction |
Author
lambdalisue
commented
Mar 26, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment