Skip to content

Commit

Permalink
fmt README
Browse files Browse the repository at this point in the history
  • Loading branch information
ringsaturn committed Aug 19, 2023
1 parent 98961f2 commit a927c2f
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

![Time zone map of the world](https://github.com/ringsaturn/tzf/blob/gh-pages/docs/tzf-social-media.png?raw=true)

**NOTE**: This package uses simplified shape data so it is not entirely accurate around the border.
**NOTE**: This package uses simplified shape data so it is not entirely accurate
around the border.

## Build options

By default, the binary is built as well. If you don't want/need it, you can omit the default features and build like this:
By default, the binary is built as well. If you don't want/need it, you can omit
the default features and build like this:

```bash
cargo build --no-default-features
Expand All @@ -20,8 +22,9 @@ cargo add tzf-rs --no-default-features

## Best Practices

It's expensive to init tzf-rs's `Finder`/`FuzzyFinder`/`DefaultFinder`, so please
consider reusing instances or creating one as a global variable. Below is a global variable example:
It's expensive to init tzf-rs's `Finder`/`FuzzyFinder`/`DefaultFinder`, so
please consider reusing instances or creating one as a global variable. Below is
a global variable example:

```rust
use lazy_static::lazy_static;
Expand All @@ -37,28 +40,33 @@ fn main() {
}
```

For reuse, [`racemap/rust-tz-service`](https://github.com/racemap/rust-tz-service) provides a good example.
For reuse,
[`racemap/rust-tz-service`](https://github.com/racemap/rust-tz-service) provides
a good example.

A Redis protocol demo could be used here: [`ringsaturn/redizone`](https://github.com/ringsaturn/redizone).
A Redis protocol demo could be used here:
[`ringsaturn/redizone`](https://github.com/ringsaturn/redizone).

## Performance

The tzf-rs package is intended for high-performance geospatial query services,
such as weather forecasting APIs. Most queries can be returned within a very
short time, averaging around 3,000 nanoseconds (about 1,000ns slower than
with Go repo `tzf`. I will continue improving this - you can track progress
short time, averaging around 3,000 nanoseconds (about 1,000ns slower than with
Go repo `tzf`. I will continue improving this - you can track progress
[here](https://github.com/ringsaturn/geometry-rs/issues/3)).

Here is what has been done to improve performance:

1. Using pre-indexing to handle most queries takes approximately 1000 nanoseconds.
1. Using pre-indexing to handle most queries takes approximately 1000
nanoseconds.
2. Using a finely-tuned Ray Casting algorithm package
[`ringsaturn/geometry-rs`](https://github.com/ringsaturn/geometry-rs) to
verify whether a polygon contains a point.

That's all. There are no black magic tricks inside the tzf-rs.

Below is a benchmark run on global cities(about 14K), and avg time is about 3,000 ns per query:
Below is a benchmark run on global cities(about 14K), and avg time is about
3,000 ns per query:

```txt
test benches_default::bench_default_finder_random_city ... bench: 2,870 ns/iter (+/- 182)
Expand All @@ -74,8 +82,8 @@ You can view more details from latest benchmark from

## References

I have written an article about the history of `tzf`, its Rust port, and its Rust
port's Python binding; you can view it
I have written an article about the history of `tzf`, its Rust port, and its
Rust port's Python binding; you can view it
[here](https://blog.ringsaturn.me/en/posts/2023-01-31-history-of-tzf/).

- Original Go repo: [`ringsaturn/tzf`](https://github.com/ringsaturn/tzf)
Expand Down

0 comments on commit a927c2f

Please sign in to comment.