Coverage Report

Created: 2026-05-16 06:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/svt-av1/Source/Lib/Codec/svt_time.c
Line
Count
Source
1
/*
2
* Copyright(c) 2019 Intel Corporation
3
*
4
* This source code is subject to the terms of the BSD 2 Clause License and
5
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6
* was not distributed with this source code in the LICENSE file, you can
7
* obtain it at https://www.aomedia.org/license/software-license. If the Alliance for Open
8
* Media Patent License 1.0 was not distributed with this source code in the
9
* PATENTS file, you can obtain it at https://www.aomedia.org/license/patent-license.
10
*/
11
12
#ifdef _WIN32
13
#include <sys/timeb.h>
14
#include <windows.h>
15
#elif !defined(__USE_POSIX199309)
16
#define __USE_POSIX199309
17
#endif
18
19
#include <time.h>
20
21
#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && (__MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_12)
22
#define OLD_MACOS
23
#endif
24
25
#if !defined(CLOCK_MONOTONIC) && !defined(_WIN32) || defined(OLD_MACOS)
26
#include <sys/time.h>
27
#endif
28
29
#include "svt_time.h"
30
31
double svt_av1_compute_overall_elapsed_time_ms(const uint64_t start_seconds, const uint64_t start_useconds,
32
474
                                               const uint64_t finish_seconds, const uint64_t finish_useconds) {
33
474
    const int64_t s_diff = (int64_t)finish_seconds - (int64_t)start_seconds,
34
474
                  u_diff = (int64_t)finish_useconds - (int64_t)start_useconds;
35
474
    return (double)s_diff * 1000.0 + (double)u_diff / 1000.0 + 0.5;
36
474
}
37
38
1.42k
void svt_av1_get_time(uint64_t* const seconds, uint64_t* const useconds) {
39
#ifdef _WIN32
40
    struct _timeb curr_time;
41
    _ftime_s(&curr_time);
42
    *seconds  = curr_time.time;
43
    *useconds = curr_time.millitm * 1000;
44
#elif defined(CLOCK_MONOTONIC) && !defined(OLD_MACOS)
45
    struct timespec curr_time;
46
1.42k
    clock_gettime(CLOCK_MONOTONIC, &curr_time);
47
1.42k
    *seconds  = curr_time.tv_sec;
48
1.42k
    *useconds = curr_time.tv_nsec / 1000;
49
#else
50
    struct timeval curr_time;
51
    gettimeofday(&curr_time, NULL);
52
    *seconds  = curr_time.tv_sec;
53
    *useconds = curr_time.tv_usec;
54
#endif
55
1.42k
}