Re: [PATCH] mailsplit and mailinfo: gracefully handle NUL characters
- Date: Fri, 16 May 2008 10:56:35 -0400
- From: "Avery Pennarun" <apenwarr@xxxxxxxxx>
- Subject: Re: [PATCH] mailsplit and mailinfo: gracefully handle NUL characters
On 5/16/08, Johannes Schindelin <Johannes.Schindelin@xxxxxx> wrote:
> Hmpf. I hoped to get more definitive information here. Especially given
> that fgetc() is nothing more than a glorified fread() into a buffer, and
> then access the buffer.
>
> Well, at least you kind of pointed me to the _unlocked() function family.
Point taken.
/tmp $ for d in test1 test2 test3 test3u; do echo -n "$d: ";
/usr/bin/time ./$d </dev/zero; done
test1: 0.09user 0.05system 0:00.14elapsed 94%CPU
test2: 2.50user 0.05system 0:02.54elapsed 100%CPU
test3: 2.48user 0.06system 0:02.53elapsed 100%CPU
test3u: 1.05user 0.05system 0:01.10elapsed 99%CPU
fread is about 18x faster than fgetc(). getc() is the same speed as
fgetc(). getc_unlocked() is definitely faster than getc, but still at
least 7x slower than fread().
And if you think *that* sucks, you should try "c << cin" in C++ :)
Source code below.
Have fun,
Avery
=== test1.c ===
#include <stdio.h>
int main()
{
char buf[1024];
int i;
for (i = 0; i < 102400; i++)
fread(buf, 1, sizeof(buf), stdin);
}
=== test2.c ===
#include <stdio.h>
int main()
{
int i;
for (i = 0; i < 1024*102400; i++)
fgetc(stdin);
}
=== test3.c ===
#include <stdio.h>
int main()
{
int i;
for (i = 0; i < 1024*102400; i++)
getc(stdin);
}
=== test3u.c ===
#include <stdio.h>
int main()
{
int i;
for (i = 0; i < 1024*102400; i++)
getc_unlocked(stdin);
}
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html