~poldi1405/go-yenc

4b7f8f90e7289c2d0c4b7d2e5d3ae86980468126 — Moritz Poldrack 2 years ago d2905a6 hashmap
added benchmarks of hashmap
M testdata/benchmarks/README.md => testdata/benchmarks/README.md +7 -8
@@ 30,8 30,9 @@ completed pretty quick.

| Algorithm    | ns/Op Escaped | ns/Op Unescaped | ns/Op (exp. avg.)¹ | *n*th fastest |
|--------------|---------------|-----------------|--------------------|---------------|
| naive        | 2.53          | 2.51            | 2.51               | 1             |
| lookup-table | 2.61          | 2.61            | 2.61               | 2             |
| naive        | 2.40          | 2.39            | 2.39               | 1             |
| lookup-table | 2.51          | 2.51            | 2.51               | 2             |
| hashmap      | 21.05         | 20.99           | 20.99              | 4
| bootleg-simd | 13.95         | 8.48            | 8.57               | 3             |

¹) assuming random distribution of bytes and that 4/256 bytes have to be escaped.


@@ 45,12 46,10 @@ randomly generated data which is compiled into the program.

| Algorithm    | Duration | Byte      | Throughput    | *n*th fastest | Speed relative to naive |
|--------------|----------|-----------|---------------|---------------|-------------------------|
| naive        |  89.778  | 268435456 | 2.85148 MiB/s | 3             | 1.00                    |
| lookup-table |  88.559  | 268435456 | 2.89073 MiB/s | 2             | 1.01                    |
| bootleg-simd |  30.690  | 268435456 | 8.34148 MiB/s | 1             | 2.93                    |

// TODO: Try if using bufio in naive and LT levels the playingfield. Until then
// Bootleg-SIMD is the winner
| naive        |  93.583  | 268435456 | 2.73554 MiB/s | 3             | 1.00                    |
| lookup-table |  93.425  | 268435456 | 2.74017 MiB/s | 2             | 1.00                    |
| hashmap      | 107.275  | 268435456 | 2.38639 MiB/s | 4             | 0.87                    |
| bootleg-simd |  29.984  | 268435456 | 8.53789 MiB/s | 1             | 3.12                    |

## additional notes


A testdata/benchmarks/data-throughput/patches/hashmap.patch => testdata/benchmarks/data-throughput/patches/hashmap.patch +29 -0
@@ 0,0 1,29 @@
diff --git a/testdata/benchmarks/README.md b/testdata/benchmarks/README.md
index 46d8ca9..6928a64 100644
--- a/testdata/benchmarks/README.md
+++ b/testdata/benchmarks/README.md
@@ -30,8 +30,9 @@ completed pretty quick.
 
 | Algorithm    | ns/Op Escaped | ns/Op Unescaped | ns/Op (exp. avg.)¹ | *n*th fastest |
 |--------------|---------------|-----------------|--------------------|---------------|
-| naive        | 2.53          | 2.51            | 2.51               | 1             |
-| lookup-table | 2.61          | 2.61            | 2.61               | 2             |
+| naive        | 2.40          | 2.39            | 2.39               | 1             |
+| lookup-table | 2.51          | 2.51            | 2.51               | 2             |
+| hashmap      | 21.05         | 20.99           | 20.99              | 4
 | bootleg-simd | 13.95         | 8.48            | 8.57               | 3             |
 
 ¹) assuming random distribution of bytes and that 4/256 bytes have to be escaped.
diff --git a/testdata/benchmarks/data-throughput/main.go b/testdata/benchmarks/data-throughput/main.go
index 88d2dfd..a835c61 100644
--- a/testdata/benchmarks/data-throughput/main.go
+++ b/testdata/benchmarks/data-throughput/main.go
@@ -22,7 +22,7 @@ func main() {
 			eof = true
 		}
 
-		b, e = yenc.YEnc(b)
+		b, e = yenc.YEncHashmap(b)
 		if e {
 			fmt.Print('=')
 		}