nim-perf experiment

This commit is contained in:
John Kerl 2016-01-19 21:32:37 -05:00
parent e00dc5f15f
commit bd1e083cd6
4 changed files with 28 additions and 0 deletions

2
perf/nimcat.nim Normal file
View file

@ -0,0 +1,2 @@
for line in stdin.lines:
echo(line)

15
perf/nimcut.nim Normal file
View file

@ -0,0 +1,15 @@
import strutils, tables
for line in stdin.lines:
#var map: OrderedTable[string,string]
var map = {"":""}.newOrderedTable
#var map = initTable[string, string]
#var map: OrderedTable[string, string]
#var map: newOrderedTable[string, string](16)
for word in line.split(","):
var pair = word.split("=")
#echo(pair[0])
#echo(pair[1])
#echo()
#map[pair[0]] = pair[1]
map.add(pair[0], pair[1])

4
perf/nimlc.nim Normal file
View file

@ -0,0 +1,4 @@
var line_count = 0
for line in stdin.lines:
line_count += 1
echo (line_count)

7
perf/nimwc.nim Normal file
View file

@ -0,0 +1,7 @@
import strutils
var word_count = 0
for line in stdin.lines:
for word in line.split(","):
word_count += 1
echo (word_count)