Skip to content

Commit ff88022

Browse files
pcloudsgitster
authored andcommitted
Revert "test-wildmatch: add "perf" command to compare wildmatch and fnmatch"
This reverts commit 1b25892. compat fnmatch will be removed soon and we can't rely on fnmatch() available everywhere. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent eb07894 commit ff88022

File tree

1 file changed

+0
-73
lines changed

1 file changed

+0
-73
lines changed

test-wildmatch.c

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -4,82 +4,9 @@
44
#include "cache.h"
55
#include "wildmatch.h"
66

7-
static int perf(int ac, char **av)
8-
{
9-
struct timeval tv1, tv2;
10-
struct stat st;
11-
int fd, i, n, flags1 = 0, flags2 = 0;
12-
char *buffer, *p;
13-
uint32_t usec1, usec2;
14-
const char *lang;
15-
const char *file = av[0];
16-
const char *pattern = av[1];
17-
18-
lang = getenv("LANG");
19-
if (lang && strcmp(lang, "C"))
20-
die("Please test it on C locale.");
21-
22-
if ((fd = open(file, O_RDONLY)) == -1 || fstat(fd, &st))
23-
die_errno("file open");
24-
25-
buffer = xmalloc(st.st_size + 2);
26-
if (read(fd, buffer, st.st_size) != st.st_size)
27-
die_errno("read");
28-
29-
buffer[st.st_size] = '\0';
30-
buffer[st.st_size + 1] = '\0';
31-
for (i = 0; i < st.st_size; i++)
32-
if (buffer[i] == '\n')
33-
buffer[i] = '\0';
34-
35-
n = atoi(av[2]);
36-
if (av[3] && !strcmp(av[3], "pathname")) {
37-
flags1 = WM_PATHNAME;
38-
flags2 = FNM_PATHNAME;
39-
}
40-
41-
gettimeofday(&tv1, NULL);
42-
for (i = 0; i < n; i++) {
43-
for (p = buffer; *p; p += strlen(p) + 1)
44-
wildmatch(pattern, p, flags1, NULL);
45-
}
46-
gettimeofday(&tv2, NULL);
47-
48-
usec1 = (uint32_t)tv2.tv_sec * 1000000 + tv2.tv_usec;
49-
usec1 -= (uint32_t)tv1.tv_sec * 1000000 + tv1.tv_usec;
50-
printf("wildmatch %ds %dus\n",
51-
(int)(usec1 / 1000000),
52-
(int)(usec1 % 1000000));
53-
54-
gettimeofday(&tv1, NULL);
55-
for (i = 0; i < n; i++) {
56-
for (p = buffer; *p; p += strlen(p) + 1)
57-
fnmatch(pattern, p, flags2);
58-
}
59-
gettimeofday(&tv2, NULL);
60-
61-
usec2 = (uint32_t)tv2.tv_sec * 1000000 + tv2.tv_usec;
62-
usec2 -= (uint32_t)tv1.tv_sec * 1000000 + tv1.tv_usec;
63-
if (usec2 > usec1)
64-
printf("fnmatch %ds %dus or %.2f%% slower\n",
65-
(int)((usec2 - usec1) / 1000000),
66-
(int)((usec2 - usec1) % 1000000),
67-
(float)(usec2 - usec1) / usec1 * 100);
68-
else
69-
printf("fnmatch %ds %dus or %.2f%% faster\n",
70-
(int)((usec1 - usec2) / 1000000),
71-
(int)((usec1 - usec2) % 1000000),
72-
(float)(usec1 - usec2) / usec1 * 100);
73-
return 0;
74-
}
75-
767
int main(int argc, char **argv)
778
{
789
int i;
79-
80-
if (!strcmp(argv[1], "perf"))
81-
return perf(argc - 2, argv + 2);
82-
8310
for (i = 2; i < argc; i++) {
8411
if (argv[i][0] == '/')
8512
die("Forward slash is not allowed at the beginning of the\n"

0 commit comments

Comments
 (0)