Skip to content

Instantly share code, notes, and snippets.

@Bennyelg
Created September 15, 2018 09:47
Show Gist options
  • Save Bennyelg/9bb47ed9a8ea195140fce6578259181e to your computer and use it in GitHub Desktop.
Save Bennyelg/9bb47ed9a8ea195140fce6578259181e to your computer and use it in GitHub Desktop.
import random
import times
import sequtils
import strutils
import strformat
type
Singleton = object
value*: int
proc newSingletone(): Singleton =
let startTime = cpuTime()
var value: int
for i in countup(0, 1_000_000):
value = rand(i)
echo(fmt"Done Computing: {cpuTime() - startTime}")
return Singleton(
value: value
)
var singletonInstance* = newSingletone()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment