Grammalecte  Check-in [9d7368b5d0]

Overview
Comment:[build][core] fix performance memo
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | core | build
Files: files | file ages | folders
SHA3-256: 9d7368b5d0f0a4114f145fb57fdb96a5471b1d8d4136cd49726cd54486a0efed
User & Date: olr on 2020-09-09 11:36:29
Other Links: manifest | tags
Context
2020-09-09
11:37
[fr] add perf_memo.txt file check-in: 88998f6977 user: olr tags: trunk, fr
11:36
[build][core] fix performance memo check-in: 9d7368b5d0 user: olr tags: trunk, core, build
11:30
[fr] faux positif check-in: dbb2b4e13c user: olr tags: trunk, fr
Changes

Modified gc_core/py/lang_core/tests_core.py from [ccfe3a8352] to [81fdf8c610].

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    finally:
        end = time.perf_counter()
        print('{} : {}'.format(label, end - start))
        if hDst:
            hDst.write("{:<12.6}".format(end-start))


def perf (sVersion, bMemo=False):
    "performance tests"
    print("Performance tests")
    gc_engine.load()
    gc_engine.parse("Text to compile rules before launching real tests.")

    spHere, _ = os.path.split(__file__)
    spfPerfTest = os.path.join(spHere, "perf.txt")
    if not os.path.exists(spfPerfTest):
        print(f"No file <perf.txt> in <{spHere}>")
        return
    with open(spfPerfTest, "r", encoding="utf-8") as hSrc:
        hDst = open("./gc_lang/"+sLang+"/perf_memo.txt", "a", encoding="utf-8", newline="\n")  if bMemo  else None
        if hDst:
            hDst.write("{:<12}{:<20}".format(sVersion, time.strftime("%Y.%m.%d %H:%M")))
        for sText in ( s.strip() for s in hSrc if not s.startswith("#") and s.strip() ):
            with timeblock(sText[:sText.find(".")], hDst):
                gc_engine.parse(sText)
        if hDst:
            hDst.write("\n")







|











|







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    finally:
        end = time.perf_counter()
        print('{} : {}'.format(label, end - start))
        if hDst:
            hDst.write("{:<12.6}".format(end-start))


def perf (sVersion, sResultFile=""):
    "performance tests"
    print("Performance tests")
    gc_engine.load()
    gc_engine.parse("Text to compile rules before launching real tests.")

    spHere, _ = os.path.split(__file__)
    spfPerfTest = os.path.join(spHere, "perf.txt")
    if not os.path.exists(spfPerfTest):
        print(f"No file <perf.txt> in <{spHere}>")
        return
    with open(spfPerfTest, "r", encoding="utf-8") as hSrc:
        hDst = open(sResultFile, "a", encoding="utf-8", newline="\n")  if sResultFile  else None
        if hDst:
            hDst.write("{:<12}{:<20}".format(sVersion, time.strftime("%Y.%m.%d %H:%M")))
        for sText in ( s.strip() for s in hSrc if not s.startswith("#") and s.strip() ):
            with timeblock(sText[:sText.find(".")], hDst):
                gc_engine.parse(sText)
        if hDst:
            hDst.write("\n")

Modified make.py from [27553159cb] to [56ef7e8bd1].

447
448
449
450
451
452
453

454
455
456
457
458
459
460
461

            if xArgs.perf or xArgs.perf_memo:
                try:
                    tests = importlib.import_module(f"grammalecte.{sLang}.tests_core")
                except ImportError:
                    print(f"# Error. Import failed: grammalecte.{sLang}.tests_core")
                else:

                    tests.perf(sVersion, xArgs.perf_memo)

            # JavaScript linter
            if xArgs.lint_web_ext:
                with helpers.CD("_build/webext/"+sLang):
                    os.system(r'web-ext lint -o text')

            # Firefox







>
|







447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462

            if xArgs.perf or xArgs.perf_memo:
                try:
                    tests = importlib.import_module(f"grammalecte.{sLang}.tests_core")
                except ImportError:
                    print(f"# Error. Import failed: grammalecte.{sLang}.tests_core")
                else:
                    sResultFile = f"gc_lang/{sLang}/perf_memo.text"  if xArgs.perf_memo  else ""
                    tests.perf(sVersion, sResultFile)

            # JavaScript linter
            if xArgs.lint_web_ext:
                with helpers.CD("_build/webext/"+sLang):
                    os.system(r'web-ext lint -o text')

            # Firefox