From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH 01/19] devtools: add simple script to find duplicate includes Date: Wed, 12 Jul 2017 14:59:25 -0700 Message-ID: <20170712145925.2dfe5be1@xeon-e3> References: <20170711185546.26138-1-stephen@networkplumber.org> <20170711185546.26138-2-stephen@networkplumber.org> <2203089.SAOtEojdoZ@xps> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: Thomas Monjalon Return-path: Received: from mail-pg0-f52.google.com (mail-pg0-f52.google.com [74.125.83.52]) by dpdk.org (Postfix) with ESMTP id 0D4312C54 for ; Wed, 12 Jul 2017 23:59:34 +0200 (CEST) Received: by mail-pg0-f52.google.com with SMTP id k14so19367509pgr.0 for ; Wed, 12 Jul 2017 14:59:33 -0700 (PDT) In-Reply-To: <2203089.SAOtEojdoZ@xps> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, 11 Jul 2017 22:33:55 +0200 Thomas Monjalon wrote: > Thank you for this script, but... it is written in Perl! > I don't think it is a good idea to add yet another language to DPDK. > We already have shell and python scripts. > And I am not sure a lot of (young) people are able to parse it ;) > > I would like to propose this shell script: > > dirs='app buildtools drivers examples lib test' > pattern='^[[:space:]]*#include[[:space:]]*[<"](.*)[>"].*' > > for file in $(git ls $dirs) ; do > dups=$(sed -rn "s,$pattern,\1,p" $file | sort | uniq -d) > [ -n "$dups" ] || continue > echo "$file" > echo "$dups" | sed 's,^,\t,' > done There is no "git ls" command in current version, Using find instead works. plus shell is 7x slower. $ time bash -c "find . -name '*.c' | xargs /tmp/dupinc.sh" real 0m0.765s user 0m1.220s sys 0m0.155s $time bash -c "find . -name '*.c' | xargs ~/bin/dup_inc.pl" real 0m0.131s user 0m0.118s sys 0m0.014s How about some python code.