findepi commented on PR #14668:
URL: https://github.com/apache/datafusion/pull/14668#issuecomment-2672254750
I bencharked
```rust
#[excalibur_function]
fn character_length(s: &str) -> i32 {
s.chars().count() as i32
}
```
comparing it with the `character_length` implementation we ship today
https://github.com/apache/datafusion/blob/f31ca5b927c040ce03f6a3c8c8dc3d7f4ef5be34/datafusion/functions/src/unicode/character_length.rs#L48-L175
I don't have expectations that generic implementation will be faster than
50x[^1] longer, hand-written and optimized code.
Rather, I wanted to check what can be a performance difference between
simple 4-liner implementation and one that has dedicated code paths for
ascii/unicode, nulls/non-nulls and Utf8/Utf8View combinations. I.e. anything
but not "simple".
<details>
<summary>The standard implementation is a bit faster at short
strings</summary>
<img width="1226" alt="image"
src="https://github.com/user-attachments/assets/a23739bb-2e24-4945-ab3e-d0d583b7c9d0"
/>
</details>
<details>
<summary>The generic implementation is a bit faster at long ASCII
strings</summary>
<img width="1188" alt="image"
src="https://github.com/user-attachments/assets/9d19c61e-d00d-4c59-9dac-989da6d2c8b3"
/>
</details>
[^1]: including unit tests code, which is natural necessity in a non-trivial
implementation, but excluding docs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]