aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc/rusage.h
blob: 725a3b6c2dff3de421baf57fa9371dde04e0dd49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * blogc: A blog compiler.
 * Copyright (C) 2014-2019 Rafael G. Martins <rafael@rafaelmartins.eng.br>
 *
 * This program can be distributed under the terms of the BSD License.
 * See the file LICENSE.
 */

#ifndef ___RUSAGE_H
#define ___RUSAGE_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /* HAVE_CONFIG_H */

#ifdef HAVE_SYS_TIME_H
#ifdef HAVE_SYS_RESOURCE_H
#define HAVE_RUSAGE 1
#endif
#endif

#include <squareball.h>

typedef struct {
    long long cpu_time;  // in microseconds
    long memory;         // in kilobytes
} blogc_rusage_t;

blogc_rusage_t* blogc_rusage_get(void);

char* blogc_rusage_format_cpu_time(long long time);
char* blogc_rusage_format_memory(long mem);

void blogc_rusage_inject(sb_trie_t *global);

#endif /* ___RUSAGE_H */