summaryrefslogtreecommitdiffstats
path: root/lib/dpkg/t/b-fsys-hash.c
blob: 7ae8f9ca2dc39098d1bf8b88325ec235bf0fc3ea (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * libdpkg - Debian packaging suite library routines
 * b-fsys-hash.c - test fsys database load and hash performance
 *
 * Copyright © 2009-2019 Guillem Jover <guillem@debian.org>
 *
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2,
 * or (at your option) any later version.
 *
 * This 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, see <https://www.gnu.org/licenses/>.
 */

#include <config.h>
#include <compat.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>

#include <dpkg/i18n.h>
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>

#include <dpkg/perf.h>

#include <dpkg/db-fsys.h>

static const char *admindir;

int
main(int argc, const char *const *argv)
{
	struct perf_slot ps;

	push_error_context();
	setvbuf(stdout, NULL, _IONBF, 0);

	admindir = dpkg_db_set_dir(admindir);

	perf_ts_mark_print("init");

	perf_ts_slot_start(&ps);
	fsys_hash_init();
	perf_ts_slot_stop(&ps);

	perf_ts_slot_print(&ps, "fsys_hash_init");

	perf_ts_slot_start(&ps);
	modstatdb_open(msdbrw_readonly | msdbrw_available_readonly);
	perf_ts_slot_stop(&ps);

	perf_ts_slot_print(&ps, "modstatdb_init");

	perf_ts_slot_start(&ps);
	ensure_allinstfiles_available_quiet();
	perf_ts_slot_stop(&ps);

	perf_ts_slot_print(&ps, "load .list");

	if (test_is_verbose()) {
		pkg_hash_report(stdout);
		fsys_hash_report(stdout);
	}

	modstatdb_shutdown();
	pop_error_context(ehflag_normaltidy);

	perf_ts_mark_print("shutdown");

	return 0;
}