2019-02-19 08:28:26 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
# Copyright 2018 the V8 project authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
""" locs.py - Count lines of code before and after preprocessor expansion
|
|
|
|
Consult --help for more information.
|
|
|
|
"""
|
|
|
|
|
2019-02-19 08:28:26 +00:00
|
|
|
# for py2/py3 compatibility
|
|
|
|
from __future__ import print_function
|
|
|
|
|
2018-11-27 13:34:02 +00:00
|
|
|
import argparse
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
import json
|
2019-04-08 10:39:55 +00:00
|
|
|
import multiprocessing
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
import os
|
2018-11-27 13:34:02 +00:00
|
|
|
import re
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
import subprocess
|
2018-11-27 13:34:02 +00:00
|
|
|
import sys
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
import tempfile
|
|
|
|
import time
|
2019-04-08 10:32:27 +00:00
|
|
|
from collections import defaultdict
|
2019-04-08 10:39:55 +00:00
|
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
|
|
from pathlib import Path
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
2019-04-05 15:19:32 +00:00
|
|
|
# for py2/py3 compatibility
|
|
|
|
try:
|
2019-04-08 10:32:27 +00:00
|
|
|
FileNotFoundError
|
2019-04-05 15:19:32 +00:00
|
|
|
except NameError:
|
2019-04-08 10:32:27 +00:00
|
|
|
FileNotFoundError = IOError
|
2019-04-05 15:19:32 +00:00
|
|
|
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
ARGPARSE = argparse.ArgumentParser(
|
2019-04-08 10:32:27 +00:00
|
|
|
description=("A script that computes LoC for a build dir"),
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
epilog="""Examples:
|
|
|
|
Count with default settings for build in out/Default:
|
|
|
|
locs.py --build-dir out/Default
|
|
|
|
Count only a custom group of files settings for build in out/Default:
|
2018-11-27 13:34:02 +00:00
|
|
|
tools/locs.py --build-dir out/Default
|
|
|
|
--group src-compiler '\.\./\.\./src/compiler'
|
|
|
|
--only src-compiler
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
Report the 10 files with the worst expansion:
|
|
|
|
tools/locs.py --build-dir out/Default --worst 10
|
|
|
|
Report the 10 files with the worst expansion in src/compiler:
|
2018-11-27 13:34:02 +00:00
|
|
|
tools/locs.py --build-dir out/Default --worst 10
|
|
|
|
--group src-compiler '\.\./\.\./src/compiler'
|
|
|
|
--only src-compiler
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
Report the 10 largest files after preprocessing:
|
|
|
|
tools/locs.py --build-dir out/Default --largest 10
|
|
|
|
Report the 10 smallest input files:
|
|
|
|
tools/locs.py --build-dir out/Default --smallest 10""",
|
|
|
|
formatter_class=argparse.RawTextHelpFormatter
|
|
|
|
)
|
|
|
|
|
|
|
|
ARGPARSE.add_argument(
|
|
|
|
'--json',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="output json instead of short summary")
|
|
|
|
ARGPARSE.add_argument(
|
|
|
|
'--build-dir',
|
|
|
|
type=str,
|
2019-04-08 10:32:27 +00:00
|
|
|
help="Use specified build dir and generate necessary files",
|
|
|
|
required=True)
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
ARGPARSE.add_argument(
|
|
|
|
'--echocmd',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="output command used to compute LoC")
|
|
|
|
ARGPARSE.add_argument(
|
|
|
|
'--only',
|
|
|
|
action='append',
|
|
|
|
default=[],
|
2018-11-27 13:34:02 +00:00
|
|
|
help="Restrict counting to report group (can be passed multiple times)")
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
ARGPARSE.add_argument(
|
|
|
|
'--not',
|
|
|
|
action='append',
|
|
|
|
default=[],
|
|
|
|
help="Exclude specific group (can be passed multiple times)")
|
|
|
|
ARGPARSE.add_argument(
|
|
|
|
'--list-groups',
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help="List groups and associated regular expressions")
|
|
|
|
ARGPARSE.add_argument(
|
|
|
|
'--group',
|
|
|
|
nargs=2,
|
|
|
|
action='append',
|
|
|
|
default=[],
|
|
|
|
help="Add a report group (can be passed multiple times)")
|
|
|
|
ARGPARSE.add_argument(
|
|
|
|
'--largest',
|
|
|
|
type=int,
|
|
|
|
nargs='?',
|
|
|
|
default=0,
|
|
|
|
const=3,
|
|
|
|
help="Output the n largest files after preprocessing")
|
|
|
|
ARGPARSE.add_argument(
|
|
|
|
'--worst',
|
|
|
|
type=int,
|
|
|
|
nargs='?',
|
|
|
|
default=0,
|
|
|
|
const=3,
|
|
|
|
help="Output the n files with worst expansion by preprocessing")
|
|
|
|
ARGPARSE.add_argument(
|
|
|
|
'--smallest',
|
|
|
|
type=int,
|
|
|
|
nargs='?',
|
|
|
|
default=0,
|
|
|
|
const=3,
|
|
|
|
help="Output the n smallest input files")
|
|
|
|
ARGPARSE.add_argument(
|
|
|
|
'--files',
|
|
|
|
type=int,
|
|
|
|
nargs='?',
|
|
|
|
default=0,
|
|
|
|
const=3,
|
|
|
|
help="Output results for each file separately")
|
2019-04-08 10:39:55 +00:00
|
|
|
ARGPARSE.add_argument(
|
|
|
|
'--jobs',
|
|
|
|
type=int,
|
|
|
|
default=multiprocessing.cpu_count(),
|
|
|
|
help="Process specified number of files concurrently")
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
|
|
|
ARGS = vars(ARGPARSE.parse_args())
|
|
|
|
|
|
|
|
|
|
|
|
def MaxWidth(strings):
|
|
|
|
max_width = 0
|
|
|
|
for s in strings:
|
|
|
|
max_width = max(max_width, len(s))
|
|
|
|
return max_width
|
|
|
|
|
|
|
|
|
2019-04-08 10:32:27 +00:00
|
|
|
def GenerateCompileCommandsAndBuild(build_dir, out):
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
if not os.path.isdir(build_dir):
|
2018-11-27 13:34:02 +00:00
|
|
|
print("Error: Specified build dir {} is not a directory.".format(
|
|
|
|
build_dir), file=sys.stderr)
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
exit(1)
|
2019-03-29 13:50:40 +00:00
|
|
|
|
|
|
|
autoninja = "autoninja -C {}".format(build_dir)
|
|
|
|
if subprocess.call(autoninja, shell=True, stdout=out) != 0:
|
|
|
|
print("Error: Building {} failed.".format(build_dir), file=sys.stderr)
|
|
|
|
exit(1)
|
|
|
|
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
compile_commands_file = "{}/compile_commands.json".format(build_dir)
|
2018-11-27 13:34:02 +00:00
|
|
|
print("Generating compile commands in {}.".format(
|
|
|
|
compile_commands_file), file=out)
|
|
|
|
ninja = "ninja -C {} -t compdb cxx cc > {}".format(
|
|
|
|
build_dir, compile_commands_file)
|
2018-12-14 11:52:21 +00:00
|
|
|
if subprocess.call(ninja, shell=True, stdout=out) != 0:
|
|
|
|
print("Error: Cound not generate {} for {}.".format(
|
2019-03-29 13:50:40 +00:00
|
|
|
compile_commands_file, build_dir), file=sys.stderr)
|
2018-12-14 11:52:21 +00:00
|
|
|
exit(1)
|
|
|
|
|
2019-04-08 10:32:27 +00:00
|
|
|
ninja_deps_file = "{}/ninja-deps.txt".format(build_dir)
|
|
|
|
print("Generating ninja dependencies in {}.".format(
|
|
|
|
ninja_deps_file), file=out)
|
|
|
|
ninja = "ninja -C {} -t deps > {}".format(
|
|
|
|
build_dir, ninja_deps_file)
|
|
|
|
if subprocess.call(ninja, shell=True, stdout=out) != 0:
|
|
|
|
print("Error: Cound not generate {} for {}.".format(
|
|
|
|
ninja_deps_file, build_dir), file=sys.stderr)
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
return compile_commands_file, ninja_deps_file
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
2019-03-29 13:50:40 +00:00
|
|
|
|
|
|
|
def fmt_bytes(num_bytes):
|
|
|
|
if num_bytes > 1024*1024*1024:
|
|
|
|
return int(num_bytes / (1024*1024)), "MB"
|
|
|
|
elif num_bytes > 1024*1024:
|
|
|
|
return int(num_bytes / (1024)), "kB"
|
|
|
|
return int(num_bytes), " B"
|
[tools] Also count input bytes in tools/locs.py
As Marja suggested, this CL changes tools/locs.py in such a way that
it also counts the bytes in the input file and the output file.
Example output now looks similar to this:
Processed 1,526 files in 24.58 sec.
gen ( 31 files): 94,507 LoC ( 4,972 kB) to 2,839,311 LoC (183,777 kB) ( 30x)
src ( 630 files): 371,499 LoC ( 14,743 kB) to 53,707,841 LoC ( 3,155 MB) ( 145x)
test ( 381 files): 492,861 LoC ( 25,372 kB) to 36,885,988 LoC ( 2,194 MB) ( 75x)
third_party ( 433 files): 239,155 LoC ( 8,683 kB) to 9,713,872 LoC (412,829 kB) ( 41x)
total ( 1526 files): 1,212,675 LoC ( 54,242 kB) to 104,133,982 LoC ( 5,973 MB) ( 86x)
Change-Id: I1ff5e752ee3a96d388a4393c2592aec68f834000
Notry: true
Reviewed-on: https://chromium-review.googlesource.com/c/1450113
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59322}
2019-02-04 09:32:09 +00:00
|
|
|
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
|
|
|
class CompilationData:
|
[tools] Also count input bytes in tools/locs.py
As Marja suggested, this CL changes tools/locs.py in such a way that
it also counts the bytes in the input file and the output file.
Example output now looks similar to this:
Processed 1,526 files in 24.58 sec.
gen ( 31 files): 94,507 LoC ( 4,972 kB) to 2,839,311 LoC (183,777 kB) ( 30x)
src ( 630 files): 371,499 LoC ( 14,743 kB) to 53,707,841 LoC ( 3,155 MB) ( 145x)
test ( 381 files): 492,861 LoC ( 25,372 kB) to 36,885,988 LoC ( 2,194 MB) ( 75x)
third_party ( 433 files): 239,155 LoC ( 8,683 kB) to 9,713,872 LoC (412,829 kB) ( 41x)
total ( 1526 files): 1,212,675 LoC ( 54,242 kB) to 104,133,982 LoC ( 5,973 MB) ( 86x)
Change-Id: I1ff5e752ee3a96d388a4393c2592aec68f834000
Notry: true
Reviewed-on: https://chromium-review.googlesource.com/c/1450113
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59322}
2019-02-04 09:32:09 +00:00
|
|
|
def __init__(self, loc, in_bytes, expanded, expanded_bytes):
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
self.loc = loc
|
[tools] Also count input bytes in tools/locs.py
As Marja suggested, this CL changes tools/locs.py in such a way that
it also counts the bytes in the input file and the output file.
Example output now looks similar to this:
Processed 1,526 files in 24.58 sec.
gen ( 31 files): 94,507 LoC ( 4,972 kB) to 2,839,311 LoC (183,777 kB) ( 30x)
src ( 630 files): 371,499 LoC ( 14,743 kB) to 53,707,841 LoC ( 3,155 MB) ( 145x)
test ( 381 files): 492,861 LoC ( 25,372 kB) to 36,885,988 LoC ( 2,194 MB) ( 75x)
third_party ( 433 files): 239,155 LoC ( 8,683 kB) to 9,713,872 LoC (412,829 kB) ( 41x)
total ( 1526 files): 1,212,675 LoC ( 54,242 kB) to 104,133,982 LoC ( 5,973 MB) ( 86x)
Change-Id: I1ff5e752ee3a96d388a4393c2592aec68f834000
Notry: true
Reviewed-on: https://chromium-review.googlesource.com/c/1450113
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59322}
2019-02-04 09:32:09 +00:00
|
|
|
self.in_bytes = in_bytes
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
self.expanded = expanded
|
[tools] Also count input bytes in tools/locs.py
As Marja suggested, this CL changes tools/locs.py in such a way that
it also counts the bytes in the input file and the output file.
Example output now looks similar to this:
Processed 1,526 files in 24.58 sec.
gen ( 31 files): 94,507 LoC ( 4,972 kB) to 2,839,311 LoC (183,777 kB) ( 30x)
src ( 630 files): 371,499 LoC ( 14,743 kB) to 53,707,841 LoC ( 3,155 MB) ( 145x)
test ( 381 files): 492,861 LoC ( 25,372 kB) to 36,885,988 LoC ( 2,194 MB) ( 75x)
third_party ( 433 files): 239,155 LoC ( 8,683 kB) to 9,713,872 LoC (412,829 kB) ( 41x)
total ( 1526 files): 1,212,675 LoC ( 54,242 kB) to 104,133,982 LoC ( 5,973 MB) ( 86x)
Change-Id: I1ff5e752ee3a96d388a4393c2592aec68f834000
Notry: true
Reviewed-on: https://chromium-review.googlesource.com/c/1450113
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59322}
2019-02-04 09:32:09 +00:00
|
|
|
self.expanded_bytes = expanded_bytes
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
|
|
|
def ratio(self):
|
|
|
|
return self.expanded / (self.loc+1)
|
|
|
|
|
|
|
|
def to_string(self):
|
[tools] Also count input bytes in tools/locs.py
As Marja suggested, this CL changes tools/locs.py in such a way that
it also counts the bytes in the input file and the output file.
Example output now looks similar to this:
Processed 1,526 files in 24.58 sec.
gen ( 31 files): 94,507 LoC ( 4,972 kB) to 2,839,311 LoC (183,777 kB) ( 30x)
src ( 630 files): 371,499 LoC ( 14,743 kB) to 53,707,841 LoC ( 3,155 MB) ( 145x)
test ( 381 files): 492,861 LoC ( 25,372 kB) to 36,885,988 LoC ( 2,194 MB) ( 75x)
third_party ( 433 files): 239,155 LoC ( 8,683 kB) to 9,713,872 LoC (412,829 kB) ( 41x)
total ( 1526 files): 1,212,675 LoC ( 54,242 kB) to 104,133,982 LoC ( 5,973 MB) ( 86x)
Change-Id: I1ff5e752ee3a96d388a4393c2592aec68f834000
Notry: true
Reviewed-on: https://chromium-review.googlesource.com/c/1450113
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59322}
2019-02-04 09:32:09 +00:00
|
|
|
exp_bytes, exp_unit = fmt_bytes(self.expanded_bytes)
|
|
|
|
in_bytes, in_unit = fmt_bytes(self.in_bytes)
|
|
|
|
return "{:>9,} LoC ({:>7,} {}) to {:>12,} LoC ({:>7,} {}) ({:>5.0f}x)".format(
|
|
|
|
self.loc, in_bytes, in_unit, self.expanded, exp_bytes, exp_unit, self.ratio())
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
2019-03-29 13:50:40 +00:00
|
|
|
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
class File(CompilationData):
|
2019-03-29 13:50:40 +00:00
|
|
|
def __init__(self, file, target, loc, in_bytes, expanded, expanded_bytes):
|
[tools] Also count input bytes in tools/locs.py
As Marja suggested, this CL changes tools/locs.py in such a way that
it also counts the bytes in the input file and the output file.
Example output now looks similar to this:
Processed 1,526 files in 24.58 sec.
gen ( 31 files): 94,507 LoC ( 4,972 kB) to 2,839,311 LoC (183,777 kB) ( 30x)
src ( 630 files): 371,499 LoC ( 14,743 kB) to 53,707,841 LoC ( 3,155 MB) ( 145x)
test ( 381 files): 492,861 LoC ( 25,372 kB) to 36,885,988 LoC ( 2,194 MB) ( 75x)
third_party ( 433 files): 239,155 LoC ( 8,683 kB) to 9,713,872 LoC (412,829 kB) ( 41x)
total ( 1526 files): 1,212,675 LoC ( 54,242 kB) to 104,133,982 LoC ( 5,973 MB) ( 86x)
Change-Id: I1ff5e752ee3a96d388a4393c2592aec68f834000
Notry: true
Reviewed-on: https://chromium-review.googlesource.com/c/1450113
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59322}
2019-02-04 09:32:09 +00:00
|
|
|
super().__init__(loc, in_bytes, expanded, expanded_bytes)
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
self.file = file
|
2019-03-29 13:50:40 +00:00
|
|
|
self.target = target
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
|
|
|
def to_string(self):
|
2019-03-29 13:50:40 +00:00
|
|
|
return "{} {} {}".format(super().to_string(), self.file, self.target)
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Group(CompilationData):
|
|
|
|
def __init__(self, name, regexp_string):
|
[tools] Also count input bytes in tools/locs.py
As Marja suggested, this CL changes tools/locs.py in such a way that
it also counts the bytes in the input file and the output file.
Example output now looks similar to this:
Processed 1,526 files in 24.58 sec.
gen ( 31 files): 94,507 LoC ( 4,972 kB) to 2,839,311 LoC (183,777 kB) ( 30x)
src ( 630 files): 371,499 LoC ( 14,743 kB) to 53,707,841 LoC ( 3,155 MB) ( 145x)
test ( 381 files): 492,861 LoC ( 25,372 kB) to 36,885,988 LoC ( 2,194 MB) ( 75x)
third_party ( 433 files): 239,155 LoC ( 8,683 kB) to 9,713,872 LoC (412,829 kB) ( 41x)
total ( 1526 files): 1,212,675 LoC ( 54,242 kB) to 104,133,982 LoC ( 5,973 MB) ( 86x)
Change-Id: I1ff5e752ee3a96d388a4393c2592aec68f834000
Notry: true
Reviewed-on: https://chromium-review.googlesource.com/c/1450113
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59322}
2019-02-04 09:32:09 +00:00
|
|
|
super().__init__(0, 0, 0, 0)
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
self.name = name
|
|
|
|
self.count = 0
|
|
|
|
self.regexp = re.compile(regexp_string)
|
|
|
|
|
|
|
|
def account(self, unit):
|
|
|
|
if (self.regexp.match(unit.file)):
|
|
|
|
self.loc += unit.loc
|
[tools] Also count input bytes in tools/locs.py
As Marja suggested, this CL changes tools/locs.py in such a way that
it also counts the bytes in the input file and the output file.
Example output now looks similar to this:
Processed 1,526 files in 24.58 sec.
gen ( 31 files): 94,507 LoC ( 4,972 kB) to 2,839,311 LoC (183,777 kB) ( 30x)
src ( 630 files): 371,499 LoC ( 14,743 kB) to 53,707,841 LoC ( 3,155 MB) ( 145x)
test ( 381 files): 492,861 LoC ( 25,372 kB) to 36,885,988 LoC ( 2,194 MB) ( 75x)
third_party ( 433 files): 239,155 LoC ( 8,683 kB) to 9,713,872 LoC (412,829 kB) ( 41x)
total ( 1526 files): 1,212,675 LoC ( 54,242 kB) to 104,133,982 LoC ( 5,973 MB) ( 86x)
Change-Id: I1ff5e752ee3a96d388a4393c2592aec68f834000
Notry: true
Reviewed-on: https://chromium-review.googlesource.com/c/1450113
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59322}
2019-02-04 09:32:09 +00:00
|
|
|
self.in_bytes += unit.in_bytes
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
self.expanded += unit.expanded
|
[tools] Also count input bytes in tools/locs.py
As Marja suggested, this CL changes tools/locs.py in such a way that
it also counts the bytes in the input file and the output file.
Example output now looks similar to this:
Processed 1,526 files in 24.58 sec.
gen ( 31 files): 94,507 LoC ( 4,972 kB) to 2,839,311 LoC (183,777 kB) ( 30x)
src ( 630 files): 371,499 LoC ( 14,743 kB) to 53,707,841 LoC ( 3,155 MB) ( 145x)
test ( 381 files): 492,861 LoC ( 25,372 kB) to 36,885,988 LoC ( 2,194 MB) ( 75x)
third_party ( 433 files): 239,155 LoC ( 8,683 kB) to 9,713,872 LoC (412,829 kB) ( 41x)
total ( 1526 files): 1,212,675 LoC ( 54,242 kB) to 104,133,982 LoC ( 5,973 MB) ( 86x)
Change-Id: I1ff5e752ee3a96d388a4393c2592aec68f834000
Notry: true
Reviewed-on: https://chromium-review.googlesource.com/c/1450113
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59322}
2019-02-04 09:32:09 +00:00
|
|
|
self.expanded_bytes += unit.expanded_bytes
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
self.count += 1
|
|
|
|
|
|
|
|
def to_string(self, name_width):
|
2018-11-27 13:34:02 +00:00
|
|
|
return "{:<{}} ({:>5} files): {}".format(
|
|
|
|
self.name, name_width, self.count, super().to_string())
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
def SetupReportGroups():
|
|
|
|
default_report_groups = {"total": '.*',
|
|
|
|
"src": '\\.\\./\\.\\./src',
|
|
|
|
"test": '\\.\\./\\.\\./test',
|
|
|
|
"third_party": '\\.\\./\\.\\./third_party',
|
|
|
|
"gen": 'gen'}
|
|
|
|
|
2019-02-24 19:18:08 +00:00
|
|
|
report_groups = default_report_groups.copy()
|
|
|
|
report_groups.update(dict(ARGS['group']))
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
|
|
|
if ARGS['only']:
|
|
|
|
for only_arg in ARGS['only']:
|
|
|
|
if not only_arg in report_groups.keys():
|
|
|
|
print("Error: specified report group '{}' is not defined.".format(
|
|
|
|
ARGS['only']))
|
|
|
|
exit(1)
|
|
|
|
else:
|
|
|
|
report_groups = {
|
|
|
|
k: v for (k, v) in report_groups.items() if k in ARGS['only']}
|
|
|
|
|
|
|
|
if ARGS['not']:
|
|
|
|
report_groups = {
|
|
|
|
k: v for (k, v) in report_groups.items() if k not in ARGS['not']}
|
|
|
|
|
|
|
|
if ARGS['list_groups']:
|
|
|
|
print_cat_max_width = MaxWidth(list(report_groups.keys()) + ["Category"])
|
|
|
|
print(" {:<{}} {}".format("Category",
|
|
|
|
print_cat_max_width, "Regular expression"))
|
|
|
|
for cat, regexp_string in report_groups.items():
|
|
|
|
print(" {:<{}}: {}".format(
|
|
|
|
cat, print_cat_max_width, regexp_string))
|
|
|
|
|
|
|
|
report_groups = {k: Group(k, v) for (k, v) in report_groups.items()}
|
|
|
|
|
|
|
|
return report_groups
|
|
|
|
|
|
|
|
|
|
|
|
class Results:
|
|
|
|
def __init__(self):
|
|
|
|
self.groups = SetupReportGroups()
|
2018-12-14 11:52:21 +00:00
|
|
|
self.units = {}
|
2019-04-08 10:32:27 +00:00
|
|
|
self.source_dependencies = {}
|
|
|
|
self.header_dependents = {}
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
2018-11-27 13:34:02 +00:00
|
|
|
def track(self, filename):
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
is_tracked = False
|
|
|
|
for group in self.groups.values():
|
|
|
|
if group.regexp.match(filename):
|
|
|
|
is_tracked = True
|
|
|
|
return is_tracked
|
|
|
|
|
2019-03-29 13:50:40 +00:00
|
|
|
def recordFile(self, filename, targetname, loc, in_bytes, expanded, expanded_bytes):
|
|
|
|
unit = File(filename, targetname, loc, in_bytes, expanded, expanded_bytes)
|
2018-12-14 11:52:21 +00:00
|
|
|
self.units[filename] = unit
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
for group in self.groups.values():
|
|
|
|
group.account(unit)
|
|
|
|
|
|
|
|
def maxGroupWidth(self):
|
|
|
|
return MaxWidth([v.name for v in self.groups.values()])
|
|
|
|
|
2018-11-27 13:34:02 +00:00
|
|
|
def printGroupResults(self, file):
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
for key in sorted(self.groups.keys()):
|
2018-11-27 13:34:02 +00:00
|
|
|
print(self.groups[key].to_string(self.maxGroupWidth()), file=file)
|
|
|
|
|
|
|
|
def printSorted(self, key, count, reverse, out):
|
2018-12-14 11:52:21 +00:00
|
|
|
for unit in sorted(list(self.units.values()), key=key, reverse=reverse)[:count]:
|
2018-11-27 13:34:02 +00:00
|
|
|
print(unit.to_string(), file=out)
|
|
|
|
|
2019-04-08 10:32:27 +00:00
|
|
|
def addHeaderDeps(self, source_dependencies, header_dependents):
|
|
|
|
self.source_dependencies = source_dependencies
|
|
|
|
self.header_dependents = header_dependents
|
|
|
|
|
2018-11-27 13:34:02 +00:00
|
|
|
|
|
|
|
class LocsEncoder(json.JSONEncoder):
|
|
|
|
def default(self, o):
|
|
|
|
if isinstance(o, File):
|
2019-03-29 13:50:40 +00:00
|
|
|
return {"file": o.file, "target": o.target, "loc": o.loc, "in_bytes": o.in_bytes,
|
[tools] Also count input bytes in tools/locs.py
As Marja suggested, this CL changes tools/locs.py in such a way that
it also counts the bytes in the input file and the output file.
Example output now looks similar to this:
Processed 1,526 files in 24.58 sec.
gen ( 31 files): 94,507 LoC ( 4,972 kB) to 2,839,311 LoC (183,777 kB) ( 30x)
src ( 630 files): 371,499 LoC ( 14,743 kB) to 53,707,841 LoC ( 3,155 MB) ( 145x)
test ( 381 files): 492,861 LoC ( 25,372 kB) to 36,885,988 LoC ( 2,194 MB) ( 75x)
third_party ( 433 files): 239,155 LoC ( 8,683 kB) to 9,713,872 LoC (412,829 kB) ( 41x)
total ( 1526 files): 1,212,675 LoC ( 54,242 kB) to 104,133,982 LoC ( 5,973 MB) ( 86x)
Change-Id: I1ff5e752ee3a96d388a4393c2592aec68f834000
Notry: true
Reviewed-on: https://chromium-review.googlesource.com/c/1450113
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59322}
2019-02-04 09:32:09 +00:00
|
|
|
"expanded": o.expanded, "expanded_bytes": o.expanded_bytes}
|
2018-11-27 13:34:02 +00:00
|
|
|
if isinstance(o, Group):
|
[tools] Also count input bytes in tools/locs.py
As Marja suggested, this CL changes tools/locs.py in such a way that
it also counts the bytes in the input file and the output file.
Example output now looks similar to this:
Processed 1,526 files in 24.58 sec.
gen ( 31 files): 94,507 LoC ( 4,972 kB) to 2,839,311 LoC (183,777 kB) ( 30x)
src ( 630 files): 371,499 LoC ( 14,743 kB) to 53,707,841 LoC ( 3,155 MB) ( 145x)
test ( 381 files): 492,861 LoC ( 25,372 kB) to 36,885,988 LoC ( 2,194 MB) ( 75x)
third_party ( 433 files): 239,155 LoC ( 8,683 kB) to 9,713,872 LoC (412,829 kB) ( 41x)
total ( 1526 files): 1,212,675 LoC ( 54,242 kB) to 104,133,982 LoC ( 5,973 MB) ( 86x)
Change-Id: I1ff5e752ee3a96d388a4393c2592aec68f834000
Notry: true
Reviewed-on: https://chromium-review.googlesource.com/c/1450113
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59322}
2019-02-04 09:32:09 +00:00
|
|
|
return {"name": o.name, "loc": o.loc, "in_bytes": o.in_bytes,
|
|
|
|
"expanded": o.expanded, "expanded_bytes": o.expanded_bytes}
|
2018-11-27 13:34:02 +00:00
|
|
|
if isinstance(o, Results):
|
2019-04-08 10:32:27 +00:00
|
|
|
return {"groups": o.groups, "units": o.units,
|
|
|
|
"source_dependencies": o.source_dependencies,
|
|
|
|
"header_dependents": o.header_dependents}
|
2018-11-27 13:34:02 +00:00
|
|
|
return json.JSONEncoder.default(self, o)
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
class StatusLine:
|
|
|
|
def __init__(self):
|
|
|
|
self.max_width = 0
|
|
|
|
|
2018-11-27 13:34:02 +00:00
|
|
|
def print(self, statusline, end="\r", file=sys.stdout):
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
self.max_width = max(self.max_width, len(statusline))
|
2019-03-29 13:50:40 +00:00
|
|
|
print("{0:<{1}}".format(statusline, self.max_width),
|
|
|
|
end=end, file=file, flush=True)
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
class CommandSplitter:
|
|
|
|
def __init__(self):
|
|
|
|
self.cmd_pattern = re.compile(
|
2018-11-27 13:34:02 +00:00
|
|
|
"([^\\s]*\\s+)?(?P<clangcmd>[^\\s]*clang.*)"
|
|
|
|
" -c (?P<infile>.*) -o (?P<outfile>.*)")
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
2019-03-29 13:50:40 +00:00
|
|
|
def process(self, compilation_unit):
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
cmd = self.cmd_pattern.match(compilation_unit['command'])
|
2019-03-29 13:50:40 +00:00
|
|
|
outfilename = cmd.group('outfile')
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
infilename = cmd.group('infile')
|
|
|
|
infile = Path(compilation_unit['directory']).joinpath(infilename)
|
2019-03-29 13:50:40 +00:00
|
|
|
return (cmd.group('clangcmd'), infilename, infile, outfilename)
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
2018-11-27 13:34:02 +00:00
|
|
|
|
2019-04-08 10:32:27 +00:00
|
|
|
def parse_ninja_deps(ninja_deps):
|
|
|
|
source_dependencies = {}
|
|
|
|
header_dependents = defaultdict(int)
|
|
|
|
current_target = None
|
|
|
|
for line in ninja_deps:
|
|
|
|
line = line.rstrip()
|
|
|
|
# Ignore empty lines
|
|
|
|
if not line:
|
|
|
|
current_target = None
|
|
|
|
continue
|
|
|
|
if line[0] == ' ':
|
|
|
|
# New dependency
|
|
|
|
if len(line) < 5 or line[0:4] != ' ' or line[5] == ' ':
|
|
|
|
sys.exit('Lines must have no indentation or exactly four ' +
|
|
|
|
'spaces.')
|
|
|
|
dep = line[4:]
|
|
|
|
if not re.search(r"\.(h|hpp)$", dep):
|
|
|
|
continue
|
|
|
|
header_dependents[dep] += 1
|
|
|
|
continue
|
|
|
|
# New target
|
|
|
|
colon_pos = line.find(':')
|
|
|
|
if colon_pos < 0:
|
|
|
|
sys.exit('Unindented line must have a colon')
|
|
|
|
if current_target is not None:
|
|
|
|
sys.exit('Missing empty line before new target')
|
|
|
|
current_target = line[0:colon_pos]
|
|
|
|
match = re.search(r"#deps (\d+)", line)
|
|
|
|
deps_number = match.group(1)
|
|
|
|
source_dependencies[current_target] = int(deps_number)
|
|
|
|
|
|
|
|
return (source_dependencies, header_dependents)
|
|
|
|
|
|
|
|
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
def Main():
|
2018-11-27 13:34:02 +00:00
|
|
|
out = sys.stdout
|
|
|
|
if ARGS['json']:
|
|
|
|
out = sys.stderr
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
2019-04-08 10:32:27 +00:00
|
|
|
compile_commands_file, ninja_deps_file = GenerateCompileCommandsAndBuild(
|
|
|
|
ARGS['build_dir'], out)
|
|
|
|
|
|
|
|
result = Results()
|
|
|
|
status = StatusLine()
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
with open(compile_commands_file) as file:
|
2019-04-08 10:39:55 +00:00
|
|
|
compile_commands = json.load(file)
|
2019-04-08 10:32:27 +00:00
|
|
|
with open(ninja_deps_file) as file:
|
|
|
|
source_dependencies, header_dependents = parse_ninja_deps(file)
|
|
|
|
result.addHeaderDeps(source_dependencies, header_dependents)
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
except FileNotFoundError:
|
2019-04-08 10:32:27 +00:00
|
|
|
print("Error: Cannot read '{}'. Consult --help to get started.".format(
|
|
|
|
ninja_deps_file))
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
exit(1)
|
|
|
|
|
2019-04-08 10:39:55 +00:00
|
|
|
cmd_splitter = CommandSplitter()
|
|
|
|
|
|
|
|
def count_lines_of_unit(ikey):
|
|
|
|
i, key = ikey
|
|
|
|
if not result.track(key['file']):
|
|
|
|
return
|
|
|
|
message = "[{}/{}] Counting LoCs of {}".format(
|
|
|
|
i, len(compile_commands), key['file'])
|
|
|
|
status.print(message, file=out)
|
|
|
|
clangcmd, infilename, infile, outfilename = cmd_splitter.process(key)
|
|
|
|
if not infile.is_file():
|
|
|
|
return
|
|
|
|
|
|
|
|
clangcmd = clangcmd + " -E -P " + \
|
|
|
|
str(infile) + " -o /dev/stdout | sed '/^\\s*$/d' | wc -lc"
|
|
|
|
loccmd = ("cat {} | sed '\\;^\\s*//;d' | sed '\\;^/\\*;d'"
|
|
|
|
" | sed '/^\\*/d' | sed '/^\\s*$/d' | wc -lc")
|
|
|
|
loccmd = loccmd.format(infile)
|
|
|
|
runcmd = " {} ; {}".format(clangcmd, loccmd)
|
|
|
|
if ARGS['echocmd']:
|
|
|
|
print(runcmd)
|
|
|
|
process = subprocess.Popen(
|
|
|
|
runcmd, shell=True, cwd=key['directory'], stdout=subprocess.PIPE)
|
|
|
|
p = {'process': process, 'infile': infilename, 'outfile': outfilename}
|
|
|
|
output, _ = p['process'].communicate()
|
|
|
|
expanded, expanded_bytes, loc, in_bytes = list(map(int, output.split()))
|
|
|
|
result.recordFile(p['infile'], p['outfile'], loc,
|
|
|
|
in_bytes, expanded, expanded_bytes)
|
|
|
|
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
with tempfile.TemporaryDirectory(dir='/tmp/', prefix="locs.") as temp:
|
|
|
|
start = time.time()
|
|
|
|
|
2019-04-08 10:39:55 +00:00
|
|
|
with ThreadPoolExecutor(max_workers=ARGS['jobs']) as executor:
|
|
|
|
list(executor.map(count_lines_of_unit, enumerate(compile_commands)))
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
|
|
|
end = time.time()
|
|
|
|
if ARGS['json']:
|
2018-11-27 13:34:02 +00:00
|
|
|
print(json.dumps(result, ensure_ascii=False, cls=LocsEncoder))
|
|
|
|
status.print("Processed {:,} files in {:,.2f} sec.".format(
|
2019-04-08 10:39:55 +00:00
|
|
|
len(compile_commands), end-start), end="\n", file=out)
|
2018-11-27 13:34:02 +00:00
|
|
|
result.printGroupResults(file=out)
|
|
|
|
|
|
|
|
if ARGS['largest']:
|
|
|
|
print("Largest {} files after expansion:".format(ARGS['largest']))
|
|
|
|
result.printSorted(
|
|
|
|
lambda v: v.expanded, ARGS['largest'], reverse=True, out=out)
|
|
|
|
|
|
|
|
if ARGS['worst']:
|
|
|
|
print("Worst expansion ({} files):".format(ARGS['worst']))
|
|
|
|
result.printSorted(
|
|
|
|
lambda v: v.ratio(), ARGS['worst'], reverse=True, out=out)
|
|
|
|
|
|
|
|
if ARGS['smallest']:
|
|
|
|
print("Smallest {} input files:".format(ARGS['smallest']))
|
|
|
|
result.printSorted(
|
|
|
|
lambda v: v.loc, ARGS['smallest'], reverse=False, out=out)
|
|
|
|
|
|
|
|
if ARGS['files']:
|
|
|
|
print("List of input files:")
|
|
|
|
result.printSorted(
|
|
|
|
lambda v: v.file, ARGS['files'], reverse=False, out=out)
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
|
|
|
|
return 0
|
|
|
|
|
2018-11-27 13:34:02 +00:00
|
|
|
|
[tools] Add script to count lines of code
This script counts lines of code before and after preprocessor expansion.
When running:
tools/locs.py --build-dir out.gn/repro --smallest --largest --worst
in the v8 directory, it reports:
Processed 1,520 files in 24.62 sec.
src ( 625 files): 365,679 to 53,468,383 ( 146.22x)
third_party ( 432 files): 239,081 to 9,502,094 ( 39.74x)
gen ( 19 files): 64,040 to 1,415,287 ( 22.10x)
total ( 1520 files): 1,173,349 to 102,831,949 ( 87.64x)
test ( 392 files): 489,865 to 37,476,036 ( 76.50x)
Largest 3 files after expansion:
33,495 to 140,401 ( 4.19x) gen/torque-generated/builtins-array-from-dsl-gen.cc
100,014 to 140,111 ( 1.40x) ../../test/cctest/gay-precision.cc
100,014 to 140,110 ( 1.40x) ../../test/cctest/gay-shortest.cc
Worst expansion (3 files):
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-data-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-function-sigs-section.cc
6 to 100,826 (14403.71x) ../../test/fuzzer/wasm-globals-section.cc
Smallest 3 input files:
0 to 0 ( 0.00x) ../../testing/gtest/empty.cc
1 to 0 ( 0.00x) ../../src/x64/simulator-x64.cc
4 to 4,423 ( 884.60x) ../../buildtools/third_party/libc++/trunk/src/utility.cpp
Notry: true
Change-Id: Ie1da942463d9e6a84338a9bd57d9ddc46d2856dc
Reviewed-on: https://chromium-review.googlesource.com/c/1349571
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57822}
2018-11-23 16:11:46 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(Main())
|