Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a better time/duration representation #122

Open
antoine-de opened this issue Mar 17, 2022 · 4 comments
Open

Use a better time/duration representation #122

antoine-de opened this issue Mar 17, 2022 · 4 comments

Comments

@antoine-de
Copy link
Collaborator

Maybe we should use std::time::Duration instead of u32 for time representation.

I'm not sure about stop_time.arrival_time / stop_time.departure_time (since it's a duration from midnight), but I least for transfers and pathways I think it would lead to better ergonomics.

@kylerchin
Copy link
Contributor

A good question to ask is, what impact would this have on memory and CPU performance of doing routing calculations? Do users want them in Duration instead of number of seconds?

worth looking into!

@lolpro11
Copy link

A good question to ask is, what impact would this have on memory and CPU performance of doing routing calculations? Do users want them in Duration instead of number of seconds?

worth looking into!

your_function:
        sub     rsp, 40
        mov     dword ptr [rsp + 20], esi
        mov     qword ptr [rsp + 24], rdi
        mov     qword ptr [rsp + 32], rdi
        add     esi, esi
        setb    al
        test    al, 1
        jne     .LBB6_2
        mov     edi, dword ptr [rsp + 20]
        call    qword ptr [rip + <T as core::convert::Into<U>>::into@GOTPCREL]
        mov     rdi, rax
        call    core::time::Duration::from_secs
        mov     qword ptr [rsp + 8], rax
        mov     ecx, edx
        mov     rdx, qword ptr [rsp + 8]
        mov     dword ptr [rsp + 16], ecx
        mov     rdi, rdx
        mov     esi, ecx
        call    <core::time::Duration as core::ops::arith::Add>::add
        mov     edi, dword ptr [rsp + 20]
        mov     rsi, qword ptr [rsp + 8]
        mov     rcx, qword ptr [rsp + 24]
        mov     rax, qword ptr [rsp + 32]
        mov     edx, dword ptr [rsp + 16]
        mov     dword ptr [rcx], edi
        mov     qword ptr [rcx + 8], rsi
        mov     dword ptr [rcx + 16], edx
        add     rsp, 40
        ret
.LBB6_2:
        lea     rdi, [rip + str.0]
        lea     rdx, [rip + .L__unnamed_8]
        mov     rax, qword ptr [rip + core::panicking::panic@GOTPCREL]
        mov     esi, 28
        call    rax
fn your_function(num: u32) -> (u32, Duration) {
    let value = num;
    let x = value + value;
    let duration = Duration::from_secs(num.into());
    let y = duration + duration;
    (value, duration)
}

Not a fan of the function call everytime a arithmetic operation is called. Overall, would take more CPU cycles and require the Struct in cache.

@Muzer
Copy link

Muzer commented May 3, 2024

Why not a NaiveTime alongside an integer for number of days?

@lolpro11
Copy link

lolpro11 commented May 3, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants