File: stats.c

package info (click to toggle)
universal-ctags 6.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,612 kB
  • sloc: ansic: 158,498; sh: 8,621; lisp: 7,742; vhdl: 6,518; cpp: 2,583; perl: 2,578; python: 2,324; javascript: 2,054; cs: 1,193; lex: 1,015; sql: 897; makefile: 787; ruby: 764; php: 755; cobol: 741; f90: 566; ada: 559; asm: 509; yacc: 465; fortran: 412; xml: 405; objc: 289; tcl: 280; java: 173; erlang: 65; pascal: 58; ml: 49; awk: 44; haskell: 42
file content (85 lines) | stat: -rw-r--r-- 2,173 bytes parent folder | download | duplicates (10)
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
82
83
84
85
/*
*   Copyright (c) 1996-2003, Darren Hiebert
*
*   Author: Darren Hiebert <dhiebert@users.sourceforge.net>
*           http://ctags.sourceforge.net
*
*   This source code is released for free distribution under the terms of the
*   GNU General Public License version 2 or (at your option) any later version.
*   It is provided on an as-is basis and no responsibility is accepted for its
*   failure to perform as expected.
*/

/*
*   INCLUDE FILES
*/
#include "general.h"  /* must always come first */

#include <stdio.h>

#include "entry_p.h"
#include "options_p.h"
#include "stats_p.h"

/*
*   MACROS
*/
#define plural(value)  (((unsigned long)(value) == 1L) ? "" : "s")

/*
*   DATA DEFINITIONS
*/
static struct { long files, lines, bytes; } Totals = { 0, 0, 0 };


/*
*   FUNCTION DEFINITIONS
*/
extern void addTotals (
		const unsigned int files, const long unsigned int lines,
		const long unsigned int bytes)
{
	Totals.files += files;
	Totals.lines += lines;
	Totals.bytes += bytes;
}

extern void printTotals (const clock_t *const timeStamps, bool append, sortType sorted)
{
	const unsigned long totalTags = numTagsTotal();
	const unsigned long addedTags = numTagsAdded();

	fprintf (stderr, "%ld file%s, %ld line%s (%ld kB) scanned",
			Totals.files, plural (Totals.files),
			Totals.lines, plural (Totals.lines),
			Totals.bytes/1024L);

	const double interval = ((double) (timeStamps [1] - timeStamps [0])) /
							CLOCKS_PER_SEC;

	fprintf (stderr, " in %.01f seconds", interval);
	if (interval != (double) 0.0)
		fprintf (stderr, " (%lu kB/s)",
				(unsigned long) (Totals.bytes / interval) / 1024L);

	fputc ('\n', stderr);

	fprintf (stderr, "%lu tag%s added to tag file",
			addedTags, plural(addedTags));
	if (append)
		fprintf (stderr, " (now %lu tags)", totalTags);
	fputc ('\n', stderr);

	if (totalTags > 0  &&  sorted != SO_UNSORTED)
	{
		fprintf (stderr, "%lu tag%s sorted", totalTags, plural (totalTags));
		fprintf (stderr, " in %.02f seconds",
				((double) (timeStamps [2] - timeStamps [1])) / CLOCKS_PER_SEC);
		fputc ('\n', stderr);
	}

#ifdef DEBUG
	fprintf (stderr, "longest tag line = %lu\n",
		 (unsigned long) maxTagsLine ());
#endif
}