Created
September 15, 2018 09:47
-
-
Save Bennyelg/9bb47ed9a8ea195140fce6578259181e to your computer and use it in GitHub Desktop.
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
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