Re: A little speed up for awk

看板DFBSD_submit作者時間21年前 (2004/10/31 06:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/7 (看更多)
:Hoi, : :We now use the one true awk in DragonFly BSD as our default. :Some people reported poor performance in some cases and, while :looking over the source, i noticed a cheap speed improvement. :Maybe you like it. : :Thx, :Andy Well, that's a fine little patch but I really doubt it will make much of a dent in awk's performance. If you really want to have a go at tracking down potential performance issues I recommend first doing some side-by-side comparisons between the old and new awk and then compiling up the new awk with profiling (-pg) and seeing if there is anything obvious in the profile output that could be fixed. The issue is likely to be algorithmic in nature. -Matt Matthew Dillon <dillon@backplane.com> :Index: tran.c :=================================================================== :RCS file: /home/dcvs/src/contrib/awk20040207/tran.c,v :retrieving revision 1.1.1.1 :diff -u -p -r1.1.1.1 tran.c :--- tran.c 17 Apr 2004 19:41:31 -0000 1.1.1.1 :+++ tran.c 1 Nov 2004 19:05:26 -0000 :@@ -396,11 +396,13 @@ char *getpssval(Cell *vp) /* get str : char *tostring(const char *s) /* make a copy of string s */ : { : char *p; :+ size_t size; : :- p = (char *) malloc(strlen(s)+1); :+ size = strlen(s) + 1; :+ p = (char *) malloc(size); : if (p == NULL) : FATAL("out of space in tostring on %s", s); :- strcpy(p, s); :+ bcopy(s, p, size); : return(p); : }
文章代碼(AID): #11X0yt00 (DFBSD_submit)
文章代碼(AID): #11X0yt00 (DFBSD_submit)