help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: still more 2.5.11 comments


From: John Millaway
Subject: Re: still more 2.5.11 comments
Date: Tue, 13 Aug 2002 09:12:17 -0700 (PDT)

> That depends on the system; older systems with slow disk
> I/O will suffer considerably. 

That remains to be seen. In the script below, I created a C file which
#includes 1000 different flex generated header files, each 57 KB.  The compile
time increases from 0.23s to 3.70s on a 466MHz. That's less than 4 milliseconds
of compile time per flex header.


Script started on Tue Aug 13 11:37:48 2002
$ ### A BASIC SCANNER
$ cat foo.l
%option reentrant nomain noyywrap nounput
%%
foo|bar         ;
fum             ;
[a-z]{4}        ;
_[[:alnum:]]+   ;
[[:digit:]]+    ;
[[:blank:]]+    ;
.|\n            ;
%%

$ ### START WITH TYPICAL C HEADERS
$ cat foo.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

$ ### CREATE 1000 DIFFERENT HEADER FILES
$ ### AND INCLUDE THEM IN foo.c
$ i=0;
$ while (( i < 1000 ))
do
    flex --header=yy$i.h -o yy.c foo.l
    echo "#include \"yy$i.h\"" >> foo.c
    i=$(( i + 1 ) )
done
$ ls -1 *.h | wc -l
   1000
$ echo "int foo(){ return 0;}" >> foo.c
$ tail -n 10 foo.c
#include "yy991.h"
#include "yy992.h"
#include "yy993.h"
#include "yy994.h"
#include "yy995.h"
#include "yy996.h"
#include "yy997.h"
#include "yy998.h"
#include "yy999.h"
int foo(){ return 0;}

$ ### CREATE foo2.c BY REMOVING THE FLEX HEADERS
$ sed '/yy/d' < foo.c >foo2.c
$ ls -l foo*.c
-rw-rw-r--    1 john     john        18992 Aug 13 11:40 foo.c
-rw-rw-r--    1 john     john          102 Aug 13 11:41 foo2.c

$ ### COMPILE foo2.c (NO FLEX HEADERS)
$ time gcc -Wall -O2 -c foo2.c
0.19user 0.01system 0:00.23elapsed 86%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (797major+464minor)pagefaults 0swaps

$ ### COMPILE foo.c (1000 FLEX HEADERS)
$ time gcc -Wall -O2 -c foo.c
2.79user 0.82system 0:03.70elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (798major+640minor)pagefaults 0swaps

$ ### PROFILE THE I/O
$ su -c '/sbin/hdparm -tT /dev/hda1'
Password: 

/dev/hda1:
 Timing buffer-cache reads:   128 MB in  2.51 seconds =51.00 MB/sec
 Timing buffered disk reads:  64 MB in 22.86 seconds = 2.80 MB/sec
$ 
Script done on Tue Aug 13 11:46:47 2002


__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]