I have been testing functions in Node and Go to compare their performance. In almost every test, Go is much faster than Node, except when strings.Fields() is used, then Node is about twice as fast.
Go:
str := "sa jasjdh asdhalsdhalsjh lasdh lasdh asds dasdhas dh asld"
arr := strings.Fields(str)
Node:
let str = 'sa jasjdh asdhalsdhalsjh lasdh lasdh asds dasdhas dh asld'
let arr = str.split(' ')
Before using strings.Fields(str), I tried strings.Split(str, " "), but it didn't work because of being a rune or something. Is there a better way to split a string into an array by a space or comma?
via Travis
No comments:
Post a Comment