Skip to content

Instantly share code, notes, and snippets.

@bjartwolf
Last active August 13, 2021 19:46
Show Gist options
  • Save bjartwolf/fa18e643da4fa57b33407db37a0e66b7 to your computer and use it in GitHub Desktop.
Save bjartwolf/fa18e643da4fa57b33407db37a0e66b7 to your computer and use it in GitHub Desktop.
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Running
open FSharp.Control.Tasks.V2
open System.Threading.Tasks
open System.Net.Http
open System.Net
open System
type Benchmarks() =
let httpClient = new HttpClient()
[<Benchmark>]
member this.Foo() : Task<unit> =
task {
let message = new HttpRequestMessage()
message.Method <- HttpMethod.Head
message.RequestUri <- Uri("https://someurlthing.com")
let! response = httpClient.SendAsync(message)
if (response.StatusCode <> HttpStatusCode.OK) then failwith "oopsy"
else return ()
}
[<EntryPoint>]
let main argv =
BenchmarkRunner.Run<Benchmarks>() |> ignore
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment