Skip to content

Commit

Permalink
Skip intermediate coord representation (#49)
Browse files Browse the repository at this point in the history
We can just build up the coords directly rather than building up arrays
and then converting them to Coords.

```
$ cargo bench --bench="*" --  --baseline=sha-6872788
   Compiling polyline v0.10.2 (/Users/mkirk/src/georust/polyline)
    Finished `bench` profile [optimized] target(s) in 0.94s
     Running benches/benchmarks.rs
(target/release/deps/benchmarks-8b91c88197106af3)
encode 10_000 coordinates at precision 1e-5
                        time:   [180.56 µs 180.85 µs 181.16 µs]
                        change: [-1.3886% -1.0790% -0.7773%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 5 outliers among 100 measurements (5.00%)
  2 (2.00%) low mild
  3 (3.00%) high mild

encode 10_000 coordinates at precision 1e-6
                        time:   [219.72 µs 220.82 µs 221.84 µs]
                        change: [+0.5301% +1.0508% +1.5979%] (p = 0.00 < 0.05)
                        Change within noise threshold.

decode 10_000 coordinates at precision 1e-5
                        time:   [80.937 µs 81.828 µs 82.713 µs]
                        change: [-4.9284% -3.9764% -2.9753%] (p = 0.00 < 0.05)
                        Performance has improved.

decode 10_000 coordinates at precision 1e-6
                        time:   [97.706 µs 98.786 µs 99.825 µs]
                        change: [-3.1947% -2.2649% -1.3617%] (p = 0.00 < 0.05)
                        Performance has improved.
```
  • Loading branch information
michaelkirk authored May 11, 2024
1 parent 6872788 commit b3a3c56
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ pub fn decode_polyline(polyline: &str, precision: u32) -> Result<LineString<f64>
});
}

coordinates.push([lon, lat]);
coordinates.push(Coord { x: lon, y: lat });
}

Ok(coordinates.into())
Ok(LineString::new(coordinates))
}

fn decode_next(
Expand Down

0 comments on commit b3a3c56

Please sign in to comment.