• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

saitoha / libsixel / 20807202489

08 Jan 2026 06:00AM UTC coverage: 55.056% (-1.6%) from 56.69%
20807202489

push

github

saitoha
ci: refine

20832 of 37838 relevant lines covered (55.06%)

1153472.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/src/timer.c
1
/*
2
 * SPDX-License-Identifier: MIT
3
 *
4
 * Copyright (c) 2025 libsixel developers. See `AUTHORS`.
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
 * this software and associated documentation files (the "Software"), to deal in
8
 * the Software without restriction, including without limitation the rights to
9
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
 * the Software, and to permit persons to whom the Software is furnished to do so,
11
 * subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in all
14
 * copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
 */ 
23
/*
24
 * High-resolution timer helpers used across libsixel.
25
 * This translation unit isolates the wall clock probe so that
26
 * lightweight frontends (Quick Look, WIC) can link the logger
27
 * without dragging in the full assessment pipeline or ONNX
28
 * dependencies.
29
 */
30

31
#if defined(HAVE_CONFIG_H)
32
#include "config.h"
33
#endif
34

35
#include "timer.h"
36
#include "compat_stub.h"
37

38
#include <sixel.h>
39

40
#include <time.h>
41

42
#if defined(_WIN32)
43
#include <windows.h>
44
#else
45
#include <unistd.h>
46
#endif
47

48
SIXELAPI double
49
sixel_assessment_timer_now(void)
17,262✔
50
{
51
#if defined(_WIN32)
52
    static LARGE_INTEGER frequency;
17,262✔
53
    LARGE_INTEGER counter;
17,262✔
54
    BOOL ok;
17,262✔
55

56
    if (frequency.QuadPart == 0) {
17,262✔
57
        ok = QueryPerformanceFrequency(&frequency);
101✔
58
        if (!ok || frequency.QuadPart == 0) {
101✔
59
            return (double)GetTickCount64() / 1000.0;
×
60
        }
61
    }
62
    QueryPerformanceCounter(&counter);
17,262✔
63
    return (double)counter.QuadPart / (double)frequency.QuadPart;
17,262✔
64
#elif defined(HAVE_CLOCK_GETTIME)
65
    struct timespec ts;
66

67
    if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
68
        return 0.0;
69
    }
70
    return (double)ts.tv_sec + (double)ts.tv_nsec / 1000000000.0;
71
#elif defined(HAVE_GETTIMEOFDAY)
72
    struct timeval tv;
73

74
    if (sixel_compat_gettimeofday(&tv) != 0) {
75
        return 0.0;
76
    }
77
    return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0;
78
#else
79
    return (double)clock() / (double)CLOCKS_PER_SEC;
80
#endif
81
}
82

83
/* emacs Local Variables:      */
84
/* emacs mode: c               */
85
/* emacs tab-width: 4          */
86
/* emacs indent-tabs-mode: nil */
87
/* emacs c-basic-offset: 4     */
88
/* emacs End:                  */
89
/* vim: set expandtab ts=4 sts=4 sw=4 : */
90
/* EOF */
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc