git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/3] wildmatch: support "no FNM_PATHNAME" mode

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Dec 20, 2012, 13:34 UTC
Message-ID
<CACsJy8AFAKEeeFMp1EF+=QyZydoyVRFqPdAKrZbPe2h4_bf=fg@mail.gmail.com>
In-Reply-To
<CACsJy8C9Nhdq_xBAOxtmLcUnrUioAMvWCPk=sBZKOzFY2WR+iA@mail.gmail.com>
On Thu, Dec 20, 2012 at 8:55 AM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
Show 6 quoted lines
>> As long as simpler patterns fnmatch() groks (namely, '?', '*', and
>> '[class]' wildcards only) are not slowed down by replacing it with
>> wildmatch(), that is, of course.
>
> I'm concerned about performance vs fnmatch too. I'll probably write a
> small program to exercise both and measure it with glibc.

I'll send out proper patches later this weekend, but unless I make big mistakes it seems wildmatch is faster than fnmatch from glibc 2.14.1 on x86-64 :) Maybe I did make mistakes. The test matches every line in /tmp/filelist.txt (which is ls-files from linux-2.6.git) 2000 times. "pathname" means FNM_PATHNAME.

$ export LANG=C $ ./test-wildmatch-perf /tmp/filelist.txt 'Documentation/*' 2000 wildmatch 1s 528394us fnmatch 2s 588396us $ ./test-wildmatch-perf /tmp/filelist.txt 'drivers/*' 2000 wildmatch 1s 957243us fnmatch 3s 134839us $ ./test-wildmatch-perf /tmp/filelist.txt 'Documentation/*' 2000 pathname wildmatch 1s 548575us fnmatch 2s 629680us $ ./test-wildmatch-perf /tmp/filelist.txt 'drivers/*' 2000 pathname wildmatch 2s 142377us fnmatch 3s 318295us $ ./test-wildmatch-perf /tmp/filelist.txt '[Dd]ocu[Mn]entation/*' 2000 wildmatch 1s 748505us fnmatch 3s 224414us $ ./test-wildmatch-perf /tmp/filelist.txt '[Dd]o?u[Mn]en?ati?n/*' 2000 wildmatch 1s 743268us fnmatch 3s 278034us $ ./test-wildmatch-perf /tmp/filelist.txt '[Dd]o?u[Mn]en?ati?n/*' 2000 pathname wildmatch 1s 745151us fnmatch 3s 314127us $ ./test-wildmatch-perf /tmp/filelist.txt nonsense 2000 pathname wildmatch 1s 310727us fnmatch 2s 279123us

-- 
Duy
Previous: Nguyen Thai Ngoc DuyNext: Nguyễn Thái Ngọc Duy
Message 7 of 11 in “Bye bye fnmatch()”
  1. 0/3 Bye bye fnmatch()Nguyễn Thái Ngọc Duy, Dec 19, 2012
  2. 1/3 wildmatch: make dowild() take arbitrary flagsNguyễn Thái Ngọc Duy, Dec 19, 2012
  3. Junio C HamanoDec 19, 2012
  4. 2/3 wildmatch: support "no FNM_PATHNAME" modeNguyễn Thái Ngọc Duy, Dec 19, 2012
  5. Junio C HamanoDec 19, 2012
  6. Nguyen Thai Ngoc DuyDec 20, 2012
  7. Nguyen Thai Ngoc DuyDec 20, 2012
  8. 3/3 Convert all fnmatch() calls to wildmatch()Nguyễn Thái Ngọc Duy, Dec 19, 2012
  9. Junio C HamanoDec 19, 2012
  10. Nguyen Thai Ngoc DuyDec 20, 2012
  11. Nguyen Thai Ngoc DuyDec 19, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.