Skip to content

Commit

Permalink
docs: set correct time magnitude
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmonstrox committed Jun 13, 2024
1 parent 534deb8 commit 3fd47ae
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/home/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ After using "locate" function, coordinates and dimensions of the object are retu

## Transforming piece of images into data

Before understanding how small pieces of images are transformed into data, tibiapi uses a hash function to implement a [Cache](https://en.wikipedia.org/wiki/Cache_(computing)) mechanism to often avoid the [OpenCV](https://opencv.org) match template and excessive [CPU](https://en.wikipedia.org/wiki/Central_processing_unit) usage, this is why many functions have responses between [milliseconds](https://simple.wikipedia.org/wiki/Millisecond) and [nanoseconds](https://en.wikipedia.org/wiki/Nanosecond):
Before understanding how small pieces of images are transformed into data, tibiapi uses a hash function to implement a [Cache](<https://en.wikipedia.org/wiki/Cache_(computing)>) mechanism to often avoid the [OpenCV](https://opencv.org) match template and excessive [CPU](https://en.wikipedia.org/wiki/Central_processing_unit) usage, this is why many functions have responses between [microseconds](https://simple.wikipedia.org/wiki/Microsecond) and [nanoseconds](https://en.wikipedia.org/wiki/Nanosecond):

```python
import numpy as np
Expand Down Expand Up @@ -59,10 +59,10 @@ Not all the code is machine code, but it would be ideal, so all the typing would

### Cache mechanism

Many functions have a [Cache](https://en.wikipedia.org/wiki/Cache_(computing)) mechanism, since some pixels are read from a specific area and it doesn't change, it is not necessary to recalculate the function, just cut out a certain region and obtain the hash of this small image generated, if the hash of this image is the same as the previous one, the value is the same.
Many functions have a [Cache](<https://en.wikipedia.org/wiki/Cache_(computing)>) mechanism, since some pixels are read from a specific area and it doesn't change, it is not necessary to recalculate the function, just cut out a certain region and obtain the hash of this small image generated, if the hash of this image is the same as the previous one, the value is the same.

Getting the hash from a image is possible using `#!python hashit` function provided in utils module. The response time should vary between 300 and 500 [nanoseconds](https://en.wikipedia.org/wiki/Nanosecond).

### Time magnitude

Small functions such as getting the level, getting the speed, etc., will respond in 5 [Microseconds](https://en.wikipedia.org/wiki/Microsecond), however, as they will be cached, the time will reduce by about 5 times and the response time will be 1 [Microseconds](https://en.wikipedia.org/wiki/Microsecond) if the content doesn't change.
Small functions such as getting the level, getting the speed, etc., will respond in 5 [microseconds](https://en.wikipedia.org/wiki/Microsecond), however, as they will be cached, the time will reduce by about 5 times and the response time will be 1 [microseconds](https://en.wikipedia.org/wiki/Microsecond) if the content doesn't change.

0 comments on commit 3fd47ae

Please sign in to comment.