Created
May 9, 2019 10:18
-
-
Save jdh30/6a656f7f30144fb71f18b1278759a7c1 to your computer and use it in GitHub Desktop.
Regular expression benchmark in F#
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
open System.Text.RegularExpressions | |
let str = System.IO.File.ReadAllText "C:\\Users\\Jon\\Documents\\pg10.txt" | |
let re = System.IO.File.ReadAllText "C:\\Users\\Jon\\Documents\\re.txt" | |
for _ in 1..3 do | |
let timer = System.Diagnostics.Stopwatch.StartNew() | |
let re = Regex(re, RegexOptions.Compiled) | |
let res = Array.Parallel.init 4 (fun _ -> re.Split str |> Seq.sumBy (fun m -> m.Length)) | |
printfn "%A %fs" res timer.Elapsed.TotalSeconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment