Skip to content

Instantly share code, notes, and snippets.

@lambdalisue
Created March 26, 2015 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lambdalisue/c73ad37a33b8242fba13 to your computer and use it in GitHub Desktop.
Save lambdalisue/c73ad37a33b8242fba13 to your computer and use it in GitHub Desktop.
Benchmark Vital.VCS.Git.Finder
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
@lambdalisue
Copy link
Author

Test1: Via git rev-parse --is-inside-work-tree
==================================================================
  2.206555
  2.590994
  2.216840
  2.384569
  2.181529
  2.196713
  2.191658
  2.499414
  2.457215
==================================================================

Test2: Via VCS.Git.Finder (with dummy cache)
==================================================================
  0.117311
  0.132775
  0.140907
  0.119070
  0.121376
  0.125802
  0.134997
  0.121216
  0.118144
==================================================================

Test2: Via VCS.Git.Finder (with file cache)
==================================================================
  0.044514
  0.039575
  0.054004
  0.048912
  0.043166
  0.047751
  0.040432
  0.043488
  0.041276
==================================================================

Test2: Via VCS.Git.Finder (with simple cache)
==================================================================
  0.024397
  0.033766
  0.024303
  0.022115
  0.021535
  0.025670
  0.021483
  0.024640
  0.022808
==================================================================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment