as-string-sink
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -109,2 +109,33 @@ import { StringSink } from "../index"; | ||
}); | ||
it("clear for less than 64 bytes capacity", () => { | ||
let sink = new StringSink("hello"); | ||
sink.clear(); | ||
expect(sink.length).toBe(0); | ||
expect(sink.capacity).toBe(64); | ||
}); | ||
it("clear for more than 64 bytes capacity", () => { | ||
let sink = new StringSink(" ".repeat(64)); | ||
sink.clear(); | ||
expect(sink.length).toBe(0); | ||
expect(sink.capacity).toBe(64); | ||
}); | ||
it("shrink for less than 64 bytes capacity", () => { | ||
let sink = new StringSink("hello"); | ||
sink.shrink(); | ||
expect(sink.length).toBe(5); | ||
expect(sink.capacity).toBe(64); | ||
}); | ||
it("shrink for more than 64 bytes capacity", () => { | ||
let sink = new StringSink(" ".repeat(33)); | ||
expect(sink.length).toBe(33); | ||
expect(sink.capacity).toBe(33 * 2); | ||
sink.shrink(); | ||
expect(sink.length).toBe(33); | ||
expect(sink.capacity).toBe(33 * 2); | ||
}); | ||
}); |
{ | ||
"name": "as-string-sink", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "An efficient dynamically sized string buffer (aka String Builder) for AssemblyScript", | ||
@@ -16,6 +16,7 @@ "keywords": [ | ||
"ascMain": "assembly/index.ts", | ||
"main": "assembly/index.ts", | ||
"scripts": { | ||
"build:untouched": "asc assembly/index.ts --target debug", | ||
"build:optimized": "asc assembly/index.ts --target release", | ||
"build:bench": "asc benchmark/index.ts -o benchmark/build/bench.wasm -b benchmark/build/bench.wasm -O3 --noAssert", | ||
"build:bench": "asc benchmark/index.ts -o benchmark/build/bench.wasm -b benchmark/build/bench.wasm -O3 --noAssert", | ||
"build": "npm run build:untouched && npm run build:optimized", | ||
@@ -28,3 +29,3 @@ "bench": "npm run build:bench && node benchmark/run.js", | ||
"@as-pect/cli": "^6.1.1", | ||
"assemblyscript": "^0.18.31" | ||
"assemblyscript": "^0.19.2" | ||
}, | ||
@@ -31,0 +32,0 @@ "files": [ |
@@ -30,3 +30,3 @@ String Sink | ||
StringSink can be up to 8700 times faster than naive string concatenation! | ||
StringSink can be up to 8700 times faster than native string concatenation! | ||
@@ -36,17 +36,17 @@ ```json | ||
------------ | ||
String += JS: 0.016 ms | ||
String += AS: 0.018 ms | ||
StringSink AS: 0.0033 ms | ||
String += JS: 0.013 ms | ||
String += AS: 0.017 ms | ||
StringSink AS: 0.0034 ms | ||
50,000 strings: | ||
--------------- | ||
String += JS: 2.86 ms | ||
String += AS: 1133.24 ms | ||
StringSink AS: 0.57 ms | ||
String += JS: 3.89 ms | ||
String += AS: 1219.44 ms | ||
StringSink AS: 0.54 ms | ||
200,000 strings: | ||
---------------- | ||
String += JS: 11.44 ms | ||
String += AS: 17867.35 ms | ||
StringSink AS: 2.06 ms | ||
String += JS: 11.29 ms | ||
String += AS: 18360.15 ms | ||
StringSink AS: 2.28 ms | ||
``` | ||
@@ -53,0 +53,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
647479
247