1
1
mirror of https://github.com/github/semantic.git synced 2024-11-22 23:29:37 +03:00

Some tag level benchmarks

This commit is contained in:
Timothy Clem 2020-07-01 16:40:08 -07:00
parent 67bcc3ca48
commit cfefa5872c
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,33 @@
module Main (main) where
import Tags.Tagging.Precise
import qualified Data.ByteString as B
import Gauge
import Source.Loc (Loc (..))
import Source.Range
import Source.Source as Source
import Source.Span (Pos (..), Span (..))
import Data.Char (ord)
main :: IO ()
main = do
bytes <- fmap fromUTF8 $ B.readFile "/Users/tclem/github/github/app/models/user.rb"
-- bytes <- fmap fromUTF8 $ B.readFile "/Users/tclem/Downloads/jquery-3.5.1.min.js"
-- let lineIndexes = B.elemIndices (toEnum (ord '\n')) (Source.bytes bytes)
defaultMain
[ baselineCalculateLine bytes
, calculateLinePRVersion bytes
, calculateLineWithMap bytes
]
baselineCalculateLine :: Source -> Benchmark
baselineCalculateLine bytes = bench "baseline calculateLineAndSpans" $ do
nf (baselineCalculateLineAndSpans bytes) (Loc (Range 73754 73757) (Span (Pos 1 73669) (Pos 1 73672)))
calculateLinePRVersion :: Source -> Benchmark
calculateLinePRVersion bytes = bench "calculateLineAndSpansPRVersion " $ do
nf (calculateLineAndSpansPRVersion bytes) (Loc (Range 73754 73757) (Span (Pos 1 73669) (Pos 1 73672)))
calculateLineWithMap :: Source -> Benchmark
calculateLineWithMap src = bench "calculateLineAndSpansWithIndexes" $ do
nf (calculateLineAndSpans src (LineIndices mempty)) (Loc (Range 73754 73757) (Span (Pos 1 73669) (Pos 1 73672)))

View File

@ -48,6 +48,8 @@ library
, semantic-source ^>= 0.1.0
, semantic-proto ^>= 0
, text ^>= 1.2.3.1
, containers
, deepseq
hs-source-dirs: src
test-suite test
@ -64,3 +66,15 @@ test-suite test
, tasty-hedgehog ^>= 1.0.0.1
, tasty-hunit >= 0.10 && <1
, text
benchmark benchmarks
import: haskell
hs-source-dirs: bench
type: exitcode-stdio-1.0
main-is: Main.hs
ghc-options: -threaded -static -rtsopts
build-depends: base
, bytestring ^>= 0.10.8.2
, semantic-tags
, semantic-source
, gauge ^>= 0.2.5