From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id CB6CF740032 for ; Fri, 6 Dec 2024 00:54:48 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=goQ7JAd1guatLuefpv+IUhM91fdXn8LvFF4jLQ/By8E=; c=relaxed/simple; d=groups.io; h=Subject:To:From:User-Agent:MIME-Version:Date:References:In-Reply-To:Message-ID:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20240830; t=1733446488; v=1; x=1733705687; b=ME630baFSWnVz6/WWoGMQ5/YGItGrkjOsuLFMZQCMSRXfHj8qPj5MbdwA84UqxIMgMVIai1G ZLd0Ya1xV8ZJwLTcbNZxqLQ8dDyJB2iwU1c6zVigGQh8B76eJx+MxQljXpFWpzkY8p3BRGdfyFt 2pgAScI0W+/da6pVpp/9nIr4Y9EAeV2GQzrrOWBOsD3yZYSy+lPAyRisu2MPxSePBjq3ZJpC3yd +cpM0SkBLiJ6EfIVXRflrFyURgEAYZGsMAQEnNe+oxBe82NbzR1AXFJ5uXsz7JNehw5Oi4SP7BC BFX4iz88Tnx/jmd6mRp3UdjsWKESlJKyFO10rNdfLxtMw== X-Received: by 127.0.0.2 with SMTP id txffYY7687511xjSrWc0LM8s; Thu, 05 Dec 2024 16:54:47 -0800 Subject: =?UTF-8?B?UmU6IFtlZGsyLWRldmVsXSDlm57lpI06IFtlZGsyLWRldmVsXSBGREYgcGFyc2VyIHBlcmZvcm1hbmNlIGRlZ3JhZGVzIHJhcGlkbHkgb24gbm9uLXRyaXZpYWxseSBzaXplZCBpbnB1dHM=?= To: "gaoliming" , devel@edk2.groups.io From: "davidr via groups.io" X-Originating-Location: Costa Mesa, California, US (70.183.63.197) X-Originating-Platform: Windows Firefox 132 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Thu, 05 Dec 2024 16:54:46 -0800 References: <018e01db46af$bd125d00$37371700$@byosoft.com.cn> In-Reply-To: <018e01db46af$bd125d00$37371700$@byosoft.com.cn> Message-ID: <15637.1733446486644216677@groups.io> Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,davidr@ghs.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 7edvmGx4av2IjPT1lKqXwV9Ex7686176AA= Content-Type: multipart/alternative; boundary="lHPBlkWwzrDtDigVZQO5" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240830 header.b=ME630baF; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io --lHPBlkWwzrDtDigVZQO5 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Here is the code I was testing with. You can probably reduce the changes do= wn to just _SkipWhiteSpace(), but I haven't tried that yet. diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source= /Python/GenFds/FdfParser.py index feb4c72779..8c57720116 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -12,6 +12,7 @@ # from __future__ import print_function from __future__ import absolute_import +from io import StringIO from re import compile, DOTALL from string import hexdigits from uuid import UUID @@ -253,7 +254,7 @@ class FdfParser: self.CurrentFdName =3D None self.CurrentFvName =3D None self._Token =3D "" - =C2=A0 =C2=A0 =C2=A0 =C2=A0self._SkippedChars =3D "" + =C2=A0 =C2=A0 =C2=A0 =C2=A0self._SkippedChars =3D StringIO() GlobalData.gFdfParser =3D self # Used to section info @@ -276,7 +277,7 @@ class FdfParser: def _SkipWhiteSpace(self): while not self._EndOfFile(): if self._CurrentChar() in {TAB_PRINTCHAR_NUL, T_CHAR_CR, TAB_LINE_BREAK, TA= B_SPACE_SPLIT, T_CHAR_TAB}: - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self._SkippedChars= +=3D str(self._CurrentChar()) + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self._SkippedChars= .write(str(self._CurrentChar())) self._GetOneChar() else: return @@ -696,7 +697,7 @@ class FdfParser: Header =3D self._Token if not self._Token.endswith(TAB_SECTION_END): self._SkipToToken(TAB_SECTION_END) - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0Header +=3D self._SkippedChars + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0Header +=3D self._SkippedChars.getvalue() if Header.find('$(') !=3D -1: raise Warning("macro cannot be used in section header", self.FileName, self= .CurrentLineNumber) self._SectionHeaderParser(Header) @@ -1226,7 +1227,7 @@ class FdfParser: raise Warning(QuoteToUse, self.FileName, self.CurrentLineNumber) if currentLineNumber !=3D self.CurrentLineNumber: raise Warning(QuoteToUse, self.FileName, self.CurrentLineNumber) - =C2=A0 =C2=A0 =C2=A0 =C2=A0self._Token =3D self._SkippedChars.rstrip(Quot= eToUse) + =C2=A0 =C2=A0 =C2=A0 =C2=A0self._Token =3D self._SkippedChars.getvalue().= rstrip(QuoteToUse) return True ## _SkipToToken() method @@ -1243,7 +1244,7 @@ class FdfParser: def _SkipToToken(self, String, IgnoreCase =3D False): StartPos =3D self.GetFileBufferPos() - =C2=A0 =C2=A0 =C2=A0 =C2=A0self._SkippedChars =3D "" + =C2=A0 =C2=A0 =C2=A0 =C2=A0self._SkippedChars =3D StringIO() while not self._EndOfFile(): index =3D -1 if IgnoreCase: @@ -1252,13 +1253,13 @@ class FdfParser: index =3D self._CurrentLine()[self.CurrentOffsetWithinLine: ].find(String) if index =3D=3D 0: self.CurrentOffsetWithinLine +=3D len(String) - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self._SkippedChars= +=3D String + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self._SkippedChars= .write(String) return True - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self._SkippedChars +=3D str(self= ._CurrentChar()) + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self._SkippedChars.write(str(sel= f._CurrentChar())) self._GetOneChar() self.SetFileBufferPos(StartPos) - =C2=A0 =C2=A0 =C2=A0 =C2=A0self._SkippedChars =3D "" + =C2=A0 =C2=A0 =C2=A0 =C2=A0self._SkippedChars =3D StringIO() return False ## GetFileBufferPos() method @@ -2890,7 +2891,7 @@ class FdfParser: if not self._SkipToToken(T_CHAR_BRACE_R): raise Warning.Expected("Depex expression ending '}'", self.FileName, self.C= urrentLineNumber) - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0DepexSectionObj.Expression =3D s= elf._SkippedChars.rstrip(T_CHAR_BRACE_R) + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0DepexSectionObj.Expression =3D s= elf._SkippedChars.getvalue().rstrip(T_CHAR_BRACE_R) Obj.SectionList.append(DepexSectionObj) elif self._IsKeyword("SUBTYPE_GUID"): @@ -3525,7 +3526,7 @@ class FdfParser: if not self._SkipToToken(TAB_SPLIT): raise Warning.Expected("'.'", self.FileName, self.CurrentLineNumber) - =C2=A0 =C2=A0 =C2=A0 =C2=A0Arch =3D self._SkippedChars.rstrip(TAB_SPLIT) + =C2=A0 =C2=A0 =C2=A0 =C2=A0Arch =3D self._SkippedChars.getvalue().rstrip(= TAB_SPLIT) ModuleType =3D self._GetModuleType() Also, if you would like to profile the build process you can apply this pat= ch. diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Pyth= on/build/build.py index 51fb1f433e..396729efd9 100755 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -2778,12 +2778,18 @@ def Main(): Log_Agent.join() return ReturnCode +import cProfile + if __name__ =3D=3D '__main__': try: mp.set_start_method('spawn') except: pass - =C2=A0 =C2=A0r =3D Main() + + =C2=A0 =C2=A0with cProfile.Profile() as pr: + =C2=A0 =C2=A0 =C2=A0 =C2=A0r =3D Main() + =C2=A0 =C2=A0 =C2=A0 =C2=A0pr.print_stats('tottime') + ## 0-127 is a safe return range, and 1 is a standard default error if r < 0 or r > 127: r =3D 1 sys.exit(r) -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#120884): https://edk2.groups.io/g/devel/message/120884 Mute This Topic: https://groups.io/mt/109931827/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --lHPBlkWwzrDtDigVZQO5 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
Here is the code I was testing with. You can probably reduce the chang= es down to just _SkipWhiteSpace(), but I haven't tried that yet.
 
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/S= ource/Python/GenFds/FdfParser.py
index feb4c72779..8c57720116 100644--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/= Source/Python/GenFds/FdfParser.py
@@ -12,6 +12,7 @@
 #
=  from __future__ import print_function
 from __future__ impo= rt absolute_import
+from io import StringIO
 from re import = compile, DOTALL
 from string import hexdigits
 from uui= d import UUID
@@ -253,7 +254,7 @@ class FdfParser:
    =      self.CurrentFdName =3D None
      &= nbsp;  self.CurrentFvName =3D None
        &n= bsp;self._Token =3D ""
-        self._SkippedChars= =3D ""
+        self._SkippedChars =3D StringIO()=
         GlobalData.gFdfParser =3D self
 
         # Used to section info
= @@ -276,7 +277,7 @@ class FdfParser:
     def _SkipWhit= eSpace(self):
         while not self._EndOfF= ile():
             if self._Curren= tChar() in {TAB_PRINTCHAR_NUL, T_CHAR_CR, TAB_LINE_BREAK, TAB_SPACE_SPLIT, = T_CHAR_TAB}:
-                = self._SkippedChars +=3D str(self._CurrentChar())
+      = ;          self._SkippedChars.write(str(self._Curr= entChar()))
                &n= bsp;self._GetOneChar()
             = ;else:
                 r= eturn
@@ -696,7 +697,7 @@ class FdfParser:
      &= nbsp;              Header =3D self._Toke= n
                   = ;  if not self._Token.endswith(TAB_SECTION_END):
    &n= bsp;                    s= elf._SkipToToken(TAB_SECTION_END)
-          =              Header +=3D self._SkippedC= hars
+                   =      Header +=3D self._SkippedChars.getvalue()
  &= nbsp;                  if Head= er.find('$(') !=3D -1:
             = ;            raise Warning("macro cannot be u= sed in section header", self.FileName, self.CurrentLineNumber)
  =                    self._= SectionHeaderParser(Header)
@@ -1226,7 +1227,7 @@ class FdfParser:
             raise Warning(QuoteToUse,= self.FileName, self.CurrentLineNumber)
        &n= bsp;if currentLineNumber !=3D self.CurrentLineNumber:
    &n= bsp;        raise Warning(QuoteToUse, self.FileName, se= lf.CurrentLineNumber)
-        self._Token =3D sel= f._SkippedChars.rstrip(QuoteToUse)
+        self._= Token =3D self._SkippedChars.getvalue().rstrip(QuoteToUse)
  &nbs= p;      return True
 
     ## = _SkipToToken() method
@@ -1243,7 +1244,7 @@ class FdfParser:
&nbs= p;    def _SkipToToken(self, String, IgnoreCase =3D False):
=          StartPos =3D self.GetFileBufferPos()
 
-        self._SkippedChars =3D ""
+ =        self._SkippedChars =3D StringIO()
  &n= bsp;      while not self._EndOfFile():
    &n= bsp;        index =3D -1
      &nbs= p;      if IgnoreCase:
@@ -1252,13 +1253,13 @@ class Fd= fParser:
                 = ;index =3D self._CurrentLine()[self.CurrentOffsetWithinLine: ].find(String)=
             if index =3D=3D 0:                 self.Curre= ntOffsetWithinLine +=3D len(String)
-         &nbs= p;      self._SkippedChars +=3D String
+     =            self._SkippedChars.write(String)                 return Tr= ue
-            self._SkippedChars +=3D = str(self._CurrentChar())
+            se= lf._SkippedChars.write(str(self._CurrentChar()))
      =        self._GetOneChar()
 
   = ;      self.SetFileBufferPos(StartPos)
-     =    self._SkippedChars =3D ""
+        se= lf._SkippedChars =3D StringIO()
         retu= rn False
 
     ## GetFileBufferPos() method<= br />@@ -2890,7 +2891,7 @@ class FdfParser:
       = ;      if not self._SkipToToken(T_CHAR_BRACE_R):
 =                raise Warning.Expec= ted("Depex expression ending '}'", self.FileName, self.CurrentLineNumber) 
-            DepexSectionObj.= Expression =3D self._SkippedChars.rstrip(T_CHAR_BRACE_R)
+   &nbs= p;        DepexSectionObj.Expression =3D self._SkippedC= hars.getvalue().rstrip(T_CHAR_BRACE_R)
        &nb= sp;    Obj.SectionList.append(DepexSectionObj)
 
&= nbsp;        elif self._IsKeyword("SUBTYPE_GUID"):
@@ -3525,7 +3526,7 @@ class FdfParser:
        &n= bsp;if not self._SkipToToken(TAB_SPLIT):
        &= nbsp;    raise Warning.Expected("'.'", self.FileName, self.Curren= tLineNumber)
 
-        Arch =3D self._S= kippedChars.rstrip(TAB_SPLIT)
+        Arch =3D se= lf._SkippedChars.getvalue().rstrip(TAB_SPLIT)
 
   = ;      ModuleType =3D self._GetModuleType()
 
 
 
Also, if you would like to profile the build process you can apply thi= s patch.
 
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source= /Python/build/build.py
index 51fb1f433e..396729efd9 100755
--- a/= BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/b= uild/build.py
@@ -2778,12 +2778,18 @@ def Main():
    &= nbsp;Log_Agent.join()
     return ReturnCode
 = ;
+import cProfile
+
 if __name__ =3D=3D '__main__':     try:
         mp.set_s= tart_method('spawn')
     except:
    &n= bsp;    pass
-    r =3D Main()
+
+  = ;  with cProfile.Profile() as pr:
+        r = =3D Main()
+        pr.print_stats('tottime')
+
     ## 0-127 is a safe return range, and 1 is a sta= ndard default error
     if r < 0 or r > 127: r = =3D 1
     sys.exit(r)
_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#120884) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--lHPBlkWwzrDtDigVZQO5--