aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/profiler/profiler.c
blob: 7d3b4e23f7fc1694f5ff9e48588f8d0cb6482021 (plain) (blame)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 *  Author: Michael Zucchi <notzed@novell.com>
 *
 *  Copyright 2005 Novell, Inc.
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of version 2 of the GNU General Public
 *  License as published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

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

#include <string.h>
#include <stdio.h>

#include <glib.h>
#include <e-util/e-profile-event.h>

void
org_gnome_evolution_profiler_event(EPlugin *ep, EProfileEventTarget *t)
{
    static FILE *fp;

    if (!fp) {
        char *name;

        name = g_strdup_printf("eprofile.%ld", (long int)getpid());
        fp = fopen(name, "w");
        if (fp)
            fprintf(stderr, "Generating profiling data in `%s'\n", name);
        g_free(name);
    }

    if (fp)
        fprintf(fp, "%d.%d: %s,%s\n", t->tv.tv_sec, t->tv.tv_usec, t->id, t->uid);
}