Skip to content

Instantly share code, notes, and snippets.

@latkin
Last active July 13, 2017 23:02
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 latkin/61f8af01b2dee03c8727f11e3dd39b44 to your computer and use it in GitHub Desktop.
Save latkin/61f8af01b2dee03c8727f11e3dd39b44 to your computer and use it in GitHub Desktop.
Ripgrep v git grep speed comparison

Environment

// OS
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.15063 N/A Build 15063
System Manufacturer:       Apple Inc.
System Model:              MacBookPro11,5
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: Intel64 Family 6 Model 70 Stepping 1 GenuineIntel ~2500 Mhz

// disk
Partitions : 6
DeviceID   : \\.\PHYSICALDRIVE0
Model      : APPLE SSD SM0512G
Size       : 500269754880
Caption    : APPLE SSD SM0512G

// ripgrep
ripgrep 0.5.2

// git
git version 2.9.2.windows.1

Setup

Clone latest master from https://github.com/microsoft/visualfsharp (commit b4c4d622135f8eb600cf032c6)

All snippets below are run in powershell.

# 3693 *.fs files, about 20.6 MiB 
> dir *.fs -File -Recurse | Measure-Object -Sum Length

Count    : 3693
Sum      : 21691047
Property : Length

Test 1

Basic search for "let bindings" in .fs files.

> rg '\blet ' -g *.fs | Measure-Object
Count    : 63566

> git grep '\blet ' *.fs | Measure-Object
Count    : 63564

> 1..10 |%{ Measure-Command { rg '\blet ' -g *.fs } } |% TotalMilliseconds | Measure-Object -max -min -average
Count    : 10
Average  : 262.38878
Maximum  : 312.5951
Minimum  : 249.32

> 1..10 |%{ Measure-Command { git grep '\blet ' *.fs } } |% TotalMilliseconds | Measure-Object -max -min -average
Count    : 10
Average  : 207.5198
Maximum  : 240.2744
Minimum  : 193.7944

Test 2

Basic search for "async" blocks

> rg '\basync\s*\{' -g *.fs | Measure-Object
Count    : 301

> git grep '\basync\s*{' *.fs | Measure-Object
Count    : 301

> 1..10 |%{ Measure-Command { rg '\basync\s*\{' -g *.fs } } |% TotalMilliseconds | Measure-Object -max -min -average
Count    : 10
Average  : 156.96702
Maximum  : 171.3596
Minimum  : 151.0885

> 1..10 |%{ Measure-Command { git grep '\basync\s*{' *.fs } } |% TotalMilliseconds | Measure-Object -max -min -average
Count    : 10
Average  : 92.89577
Maximum  : 109.9558
Minimum  : 87.6595
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment