Skip to content

Commit

Permalink
Finished cleaning up EDNReader, removed CharBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsky committed Dec 5, 2024
1 parent 53673a3 commit d715795
Show file tree
Hide file tree
Showing 5 changed files with 324 additions and 287 deletions.
19 changes: 17 additions & 2 deletions dev/bench.clj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
(->> (sort-by File/.getName)))
:let [content (slurp file)]]
(duti/benching (File/.getName file)
(doseq [[name parse-fn] [["clojure.edn" edn/read-string]
(doseq [[name parse-fn] [#_["clojure.edn" edn/read-string]
#_["tools.reader" tools/read-string]
["fast-edn" edn2/read-string]]]
(duti/benching name
Expand Down Expand Up @@ -209,9 +209,24 @@
(gen-keywords 10))
(bench-edn {:pattern #".*\.edn"}))

; 53673a3
; ------- -------
; edn_basic_10 0.115 0.122
; edn_basic_100 0.548 0.528
; edn_basic_1000 3.125 3.178
; edn_basic_10000 40.650 39.409
; edn_basic_100000 397.643 376.625
; ints_1400 35.974 30.800
; keywords_10 0.641 0.639
; keywords_100 5.720 5.730
; keywords_1000 66.411 62.685
; keywords_10000 820.167 807.494
; strings_1000 43.875 44.212
; strings_uni_250 120.249 117.282

; ┌────────────────┬─────────────┬─────────────┬─────────────┬─────────────┐
; │ keywords │ 10 │ 100 │ 1000 │ 10000 │
; ────────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
; ────────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
; │ clojure.edn │ │ │ 372.045 μs │ │
; │ fast-edn │ 0.638 µs │ 5.733 µs │ 65.429 μs │ 802.938 µs │
; └────────────────┴─────────────┴─────────────┴─────────────┴─────────────┘
99 changes: 0 additions & 99 deletions src/fast_edn/CharBuffer.java

This file was deleted.

6 changes: 3 additions & 3 deletions src/fast_edn/CharReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static boolean isDigit(int v) {
return v >= '0' && v <= '9';
}

public final char eat(IntPredicate pred) {
public final int eat(IntPredicate pred) {
char[] buffer = curBuffer;
while (buffer != null) {
final int len = buffer.length;
Expand All @@ -125,10 +125,10 @@ public final char eat(IntPredicate pred) {
}
buffer = nextBuffer();
}
return 0;
return -1;
}

public final char eatwhite() {
public final int eatwhite() {
return eat(CharReader::isWhitespace);
}

Expand Down
Loading

0 comments on commit d715795

Please sign in to comment.