Skip to content

Commit

Permalink
apply black 20.8b1 formatting update
Browse files Browse the repository at this point in the history
Summary:
allow-large-files

black_any_style

Reviewed By: zertosh

Differential Revision: D24325133

fbshipit-source-id: b4afe80d1e8b2bc993f4b8e3822c02964df47462
  • Loading branch information
amyreese authored and facebook-github-bot committed Oct 15, 2020
1 parent a867d92 commit 41009c9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 45 deletions.
50 changes: 25 additions & 25 deletions tools/hbc-attribute/accumulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,39 @@

class Accumulation:
"""Groups allocations and counts them both per group and globally.
The input is essentially:
The input is essentially:
Function Type DedupKey Size
foo.js:1 data:string:header 42 8
bar.js:1 data:string:header 42 8
bar.js:2 data:string:header 1337 8
Function Type DedupKey Size
foo.js:1 data:string:header 42 8
bar.js:1 data:string:header 42 8
bar.js:2 data:string:header 1337 8
and this is counted both globally (string header key 42 is used 2
times, 1337 once), and per filename (generally: group). foo.js uses
string header key 42, bar.js uses 42 and 1337.
and this is counted both globally (string header key 42 is used 2
times, 1337 once), and per filename (generally: group). foo.js uses
string header key 42, bar.js uses 42 and 1337.
Once all the data is counted, total space used by each group is
tallied, summed and itemized in a nested way, with three sums:
Once all the data is counted, total space used by each group is
tallied, summed and itemized in a nested way, with three sums:
* Private: Data used only by this group
* Shared: All data used by this group
* Amortized: Data used divided by number of users
* Private: Data used only by this group
* Shared: All data used by this group
* Amortized: Data used divided by number of users
In the example above, for bar.js:
In the example above, for bar.js:
* Private usage is 8 because #1337 is only used by bar.js
* Shared usage is 16, because bar.js uses #42 and #1337
* Amortized usage is 12, because bar.js owns all of #1337
but splits #42 equally with foo.js (8/1+8/2 = 12).
* Private usage is 8 because #1337 is only used by bar.js
* Shared usage is 16, because bar.js uses #42 and #1337
* Amortized usage is 12, because bar.js owns all of #1337
but splits #42 equally with foo.js (8/1+8/2 = 12).
The final result is a JSON object essentially representing:
The final result is a JSON object essentially representing:
Pri Am Shr
bar.js 8 10 24
data 8 10 24
string 8 10 24
header 8 8 16
chars 0 2 8
Pri Am Shr
bar.js 8 10 24
data 8 10 24
string 8 10 24
header 8 8 16
chars 0 2 8
"""

Expand Down
6 changes: 3 additions & 3 deletions utils/genUnicodeTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@


def print_template(s, **kwargs):
""" Substitute in the keyword arguments to the template string
(or direct template) s, and print the result, followed by a
newline.
"""Substitute in the keyword arguments to the template string
(or direct template) s, and print the result, followed by a
newline.
"""
text = Template(s).substitute(**kwargs)
print(text.strip())
Expand Down
34 changes: 17 additions & 17 deletions utils/summarize_sizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@


def metric_key_for_section_name(secname):
""" Returns an attribute name for the given section name, or None
Note that not all sections are represented.
"""Returns an attribute name for the given section name, or None
Note that not all sections are represented.
"""
if secname in ["text", "init_array", "fini_array"]:
return "code"
Expand Down Expand Up @@ -64,12 +64,12 @@ def metric_key_for_section_name(secname):


def measure_executable(path):
""" Invoke `size` and parse its output, returning a dictionary.
"""Invoke `size` and parse its output, returning a dictionary.
On Darwin, the interesting lines look like:
.rodata 366252 5048448
On Linux:
__const 25808 4295726400
On Darwin, the interesting lines look like:
.rodata 366252 5048448
On Linux:
__const 25808 4295726400
"""
metrics = {key: 0 for key in METRIC_KEYS}
reg = re.compile(
Expand Down Expand Up @@ -107,8 +107,8 @@ def measure_executable(path):


def human_readable_size(size, show_sign=False):
""" Return a human-readable string for a given byte size.
If show_sign is set, write positive numbers with a leading + sign.
"""Return a human-readable string for a given byte size.
If show_sign is set, write positive numbers with a leading + sign.
"""
if size == 0:
return "0"
Expand All @@ -120,8 +120,8 @@ def human_readable_size(size, show_sign=False):


def compare_metrics(before_metrics, after_metrics):
""" Given before and after metrics, return a dictionary describing
their differences. """
"""Given before and after metrics, return a dictionary describing
their differences."""
result = OrderedDict()
for key in METRIC_KEYS:
# Extract the leading byte count from the humanized string
Expand All @@ -132,8 +132,8 @@ def compare_metrics(before_metrics, after_metrics):


def read_or_measure_metrics(path):
""" Given a path (which may be to a JSON file or an executable),
return the metrics.
"""Given a path (which may be to a JSON file or an executable),
return the metrics.
"""
try:
with open(path) as path_fd:
Expand All @@ -143,8 +143,8 @@ def read_or_measure_metrics(path):


def subcommand_compare(args):
""" Implementation of compare subcommand
Compares two files (JSON or executables) specified in args.FILES
"""Implementation of compare subcommand
Compares two files (JSON or executables) specified in args.FILES
"""
before_path, after_path = args.FILES
before_metrics = read_or_measure_metrics(before_path)
Expand All @@ -154,8 +154,8 @@ def subcommand_compare(args):


def subcommand_measure(args):
""" Implementation of measure subcommand
Collects metrics about the files specified in args.FILES
"""Implementation of measure subcommand
Collects metrics about the files specified in args.FILES
"""
for argfile in args.FILES:
metrics = measure_executable(argfile)
Expand Down

0 comments on commit 41009c9

Please sign in to comment.