Granville Barnett

Using CPU Scheduling Simulator with F#

Just a quickie and a dead simple example, CPUSS is really easy to use with any managed language including C++/CLI, VB.NET and F# but I chose F# to create a real easy program to show the synergy between the two as you might expect is very good.

    1 #light

    2 

    3 #r @"<release dir>\Cpuss.dll"

    4 #r @"<release dir>\Cpuss.Strategies.dll"

    5 

    6 open System

    7 open Cpuss

    8 open Cpuss.Strategies

    9 

   10 let setup =

   11   let r = new Runner(10, 10, 25, new RoundRobin(5))

   12   r.Run()

   13   (r.BusyCpuTime, r.IdleCpuTime, r.GetAverageWaitTime())

   14 

   15 let stats =

   16   let busy, idle, avg = setup

   17   printfn "Busy CPU Time: %dns" busy

   18   printfn "Idle CPU Time: %dns" idle

   19   printfn "Average Wait Time: %gns" avg

Enjoy!

Comments

No Comments