Comment

Comment by fleitz

That's not bad, how about 0.014 milliseconds for 100,000 iterations? On a Core i5 @ 2.6 Ghz

  // Learn more about F# at http://fsharp.net
  open System

  let consume x = ()
  let start = System.Environment.TickCount

  Seq.init 100000 id
  |> Seq.iter (fun x ->  [0..4] |> List.filter (fun y -> (y % 2) = 0) |> consume ) 

  let endTime = System.Environment.TickCount
  printfn "%f milliseconds" (TimeSpan.FromTicks(int64(endTime - start)).TotalMilliseconds)

Output:

  0.014100 milliseconds
  Press any key to continue . . .
I'm sure if I added some java line noise I could get it up to 6 milliseconds. Too bad I didn't need a calendar class to figure out how to get from ticks to milliseconds. It's also really unfortunate that System.Environment.TickCount compiles down to a single assembly instruction. I was really hoping to use a factory pattern in there somewhere. Maybe some IOC containers. What good is a language if you can't write half your code in XML.
parent fleitz 15 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton