-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
267 additions
and
156 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,31 @@ | ||
version = "0.0.4" | ||
version = "0.0.5" | ||
author = "disruptek" | ||
description = "marshal native Nim objects via streams, channels" | ||
license = "MIT" | ||
|
||
requires "nim >= 1.0.0 & < 2.0.0" | ||
requires "https://github.com/disruptek/criterion" | ||
#requires "https://github.com/disruptek/criterion" | ||
|
||
proc execCmd(cmd: string) = | ||
echo "execCmd:" & cmd | ||
echo "exec: " & cmd | ||
exec cmd | ||
|
||
proc execTest(test: string) = | ||
execCmd "nim c -r " & test | ||
execCmd "nim c -d:danger -r " & test | ||
execCmd "nim cpp -r " & test | ||
execCmd "nim cpp -d:danger -r " & test | ||
when true: | ||
execCmd "nim c -d:danger -r " & test & " write" | ||
execCmd "nim c -d:danger -r " & test & " read" | ||
execCmd "nim c -d:danger -r " & test & " write 500" | ||
execCmd "nim c -d:danger -r " & test & " read 500" | ||
else: | ||
execCmd "nim c -r " & test & " write" | ||
execCmd "nim c -d:danger -r " & test & " read" | ||
execCmd "nim cpp -r " & test & " write" | ||
execCmd "nim cpp -d:danger -r " & test & " read" | ||
when NimMajor >= 1 and NimMinor >= 1: | ||
execCmd "nim c --useVersion:1.0 -d:danger -r " & test | ||
execCmd "nim c --gc:arc --exceptions:goto -r " & test | ||
execCmd "nim cpp --gc:arc --exceptions:goto -r " & test | ||
execCmd "nim c --useVersion:1.0 -d:danger -r " & test & " write" | ||
execCmd "nim c --useVersion:1.0 -d:danger -r " & test & " read" | ||
execCmd "nim c --gc:arc -r " & test & " write" | ||
execCmd "nim cpp --gc:arc -r " & test & " read" | ||
|
||
task test, "run tests for travis": | ||
execTest("frosty.nim") | ||
execTest("tests/test.nim") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import std/hashes | ||
import std/times | ||
import std/strutils | ||
import std/streams | ||
import std/lists | ||
import std/intsets | ||
import std/tables | ||
import std/os | ||
import std/random | ||
import std/json | ||
import std/uri | ||
|
||
import criterion | ||
|
||
import frosty | ||
|
||
const | ||
fn = "goats" | ||
let | ||
mode = if paramCount() < 1: "write" else: paramStr(1) | ||
count = if paramCount() < 2: 1 else: parseInt paramStr(2) | ||
echo "benching against " & $count & " units in " & fn | ||
|
||
let | ||
tJs = %* { | ||
"goats": ["pigs", "horses"], | ||
"sheep": 11, | ||
"ducks": 12.0, | ||
"dogs": "woof", | ||
"cats": false, | ||
"frogs": { "toads": true, "rats": "yep" }, | ||
} | ||
|
||
template writeSomething*(ss: Stream; w: typed): untyped = | ||
ss.setPosition 0 | ||
if count == 1: | ||
freeze(w, ss) | ||
else: | ||
for i in 1 .. count: | ||
freeze(w, ss) | ||
|
||
template readSomething*(ss: Stream; w: typed): untyped = | ||
var | ||
r: typeof(w) | ||
ss.setPosition 0 | ||
if count == 1: | ||
thaw(ss, r) | ||
else: | ||
for i in 1 .. count: | ||
thaw(ss, r) | ||
r | ||
|
||
const | ||
tSeq = @[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | ||
tString = "https://irclogs.nim-lang.org/01-06-2020.html#20:54:23" | ||
tObj = parseUri(tString) | ||
var | ||
tIntset = initIntSet() | ||
for i in 0 .. 10: | ||
tIntset.incl i | ||
|
||
var cfg = newDefaultConfig() | ||
cfg.budget = 0.5 | ||
|
||
benchmark cfg: | ||
var | ||
ss = newStringStream() | ||
|
||
proc write_seq() {.measure.} = | ||
ss.writeSomething tSeq | ||
|
||
proc read_seq() {.measure.} = | ||
discard ss.readSomething tSeq | ||
|
||
proc write_string() {.measure.} = | ||
ss.writeSomething tString | ||
|
||
proc read_string() {.measure.} = | ||
discard ss.readSomething tString | ||
|
||
proc write_obj() {.measure.} = | ||
ss.writeSomething tObj | ||
|
||
proc read_obj() {.measure.} = | ||
discard ss.readSomething tObj | ||
|
||
proc write_intset() {.measure.} = | ||
ss.writeSomething tIntset | ||
|
||
proc read_intset() {.measure.} = | ||
let r = ss.readSomething tIntset | ||
|
||
proc write_json() {.measure.} = | ||
ss.writeSomething tJs | ||
|
||
proc read_json() {.measure.} = | ||
let r = ss.readSomething tJs |
Oops, something went wrong.