Commit Graph

75 Commits

Author SHA1 Message Date
Arnold Schwaighofer
3312d035f9 Fix cmpsize.py -l 2024-01-12 12:25:25 -08:00
Andrew Trick
97b781626f Fix lit test Python/python_lint.swift
./utils/cmpcodesize/cmpcodesize/main.py:20:71: E231 missing whitespace after ','

./utils/round-trip-syntax-test:20:20: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`

./utils/round-trip-syntax-test:21:16: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`

I can't find any uses of round-trip-syntax-test, so I don't know if
this fix is correct.
2023-11-17 16:53:49 -08:00
Allan Shortlidge
8e5822546d Utils: Fix default arch selection bug in cmpcodesize.py.
The logic was defaulting to `arm64` when a binary only contained `amr64_32` and
`arm64e` slices.
2023-05-03 15:19:32 -07:00
Erik Eckstein
b06f0bc6d4 Fix the cmpcodesize script
It didn't survive the python3 upgrade well.
2022-05-24 11:14:12 +02:00
Daniel Duan
3dfc40898c [NFC] Remove Python 2 imports from __future__ (#42086)
The `__future__` we relied on is now,  where the 3 specific things are
all included [since Python 3.0](https://docs.python.org/3/library/__future__.html):

* absolute_import
* print_function
* unicode_literals
* division

These import statements are no-ops and are no longer necessary.
2022-04-13 14:01:30 -07:00
Meghana Gupta
0b7368d91b Add option to cmpcodesize.py to also list segment sizes
Option --additional-segments will list % change in segment sizes (__TEXT, __DATA, __LLVM_COV, __LINKEDIT)
2020-05-14 13:50:38 -07:00
Nate Chandler
5e3b9b58bd [cmpcodesize] Allowed args to specify dirs.
Previously, to specify the directories containing objects whose sizes
should be compared, environment variables had to be used.  With this
change, arguments (-o/--old-build-dir, -n/--new-build-dir) can be passed
to the cmpcodesize script directly.  If those arguments aren't
specified, the environment variables are sued as before.
2019-09-19 13:44:54 -07:00
Pavol Vaskovic
53cd115b0e [Gardening] Fix W291 trailing whitespace 2018-11-28 16:57:23 +01:00
Graydon Hoare
71da5ec519 Fix flake8 warning W605 invalid escape sequence. 2018-11-06 11:38:39 -08:00
Arnold Schwaighofer
cc7f207cec Rename swift sections from swift4 to swift5
rdar://38465220
2018-05-23 12:18:08 -07:00
Arnold Schwaighofer
0c11e1a0a3 Mark swift sections as swift4 for Swift 4.2
rdar://36363251
2018-03-14 10:27:28 -07:00
Andrew Trick
4fe9f06923 cmpcodesize: fix the sign of the percentage change.
The formula for percentage change in _any_ metric, without exception, is:

(new_value - old_value) / old_value

Some people flip the sign of their result, presumably because they
associate "positive" with "good" or want to render a graph where
"upward" bars are "good". Making this mistake consistently leads to
tremendous confusion.

This is particularly horrible when people confuse time and speed,
which are inverse metrics. Flipping the sign in order to present the
inverse metric is commonly done, but is mathematically incorrect and
is often extremely misleading. That's why it's so important to use a
standard (mathematically correct) convention for reporting a change in
percentage of any metric.

So, if I triple the size of the code, I'll now see +200%, not -200% which is
mathematically impossible and shear nonsense.
2018-02-09 13:36:03 -08:00
Alper Çugun
ed4ed8d668 Implementation of CSV output.
Added title column.

Make short parameter consistent.

Made output option -c work.

Fixed csv output for -l flag.

Shortened too long lines.

Fix linting errors.

Remove comment.
2018-02-01 09:57:12 +01:00
Arnold Schwaighofer
17cd95efa4 Rename swift3 section and global names to swift5
Such that old and new runtimes can co-exists
rdar://36363251
2018-01-22 10:04:46 -08:00
Erik Eckstein
dcef91680c cmpcodesize: replace the Ounchecked with the Osize benchmark shortcut.
To be in sync with the current benchmark build modes
2017-11-10 16:13:28 -08:00
Roman Levenstein
0cbcde2d9e [cmpcodesize] Output the percentage of the total size consumed by each category
The output now shows those percentages like this:
Generic Spec:   172758 ( 5%)    172758 ( 5%)     0.0%
  Partial Spec:     10869 ( 0%)      10869 ( 0%)      0.0%
2017-06-06 12:34:54 -07:00
Roman Levenstein
78949cd8d3 [cmpcodesize] Distinguish between full generic specializations and partial generic specializations 2017-06-06 11:37:08 -07:00
Hugh Bellamy
fa3543d3c5 Fix some pylint errors for double whitespace after class/function 2017-02-17 15:37:19 +07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
31676caa20 [gardening] PEP-8 cleanups. 2016-12-18 09:48:30 +01:00
Erik Eckstein
6390f9ebba Mangling: adapt cmpcodesize utility for new mangling 2016-12-16 08:59:26 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Alex Chan
3249a6a162 [gardening] Python tidies in cmpcodesize.main
* Actually call the `sort()` method.
* Cut out an unnecessary `idx` variable.
2016-08-24 11:08:54 +01:00
practicalswift
5a3067e24e [gardening] Fix plural issues. 2016-05-21 18:45:31 +02:00
practicalswift
1edb62dc38 [Python] Make flake8 linting pass without errors/warning (w/ default rules) 2016-03-13 20:19:51 +01:00
practicalswift
0796eaad1f [Python] Fix 80-column violations 2016-03-09 23:52:11 +01:00
Brian Gesiak
c9000af795 Merge pull request #1526 from practicalswift/fix-pep8-violations-ii
[Python] Fix five classes of PEP-8 violations (E101/E111/E128/E302/W191)
2016-03-08 23:55:46 -05:00
practicalswift
265835fdfc [Python] Use consistent import ordering for Python code
Ordering used:
1.) standard library imports
2.) third party imports
3.) local package imports

Each group is individually alphabetized.
2016-03-07 23:25:16 +01:00
practicalswift
183da818df [Python] Fix five classes of PEP-8 violations (E101/E111/E128/E302/W191)
* E101: indentation contains mixed spaces and tabs
* E111: indentation is not a multiple of four
* E128: continuation line under-indented for visual indent
* E302: expected 2 blank lines, found 1
* W191: indentation contains tabs
2016-03-07 22:36:23 +01:00
practicalswift
04afd6e640 [Python] Improve consistency: "block comment should start with '# '" (PEP-8) 2016-03-05 14:03:16 +01:00
practicalswift
e33f1747a9 [Python] Improve Python consistency: "variable in function should be lowercase" (N806)
The repo contains roughly 80 Python scripts. "snake_case" naming is used for
local variables in all those scripts. This is the form recommended by the PEP 8
naming recommendations (Python Software Foundation) and typically associated
with idiomatic Python code.

However, in nine of the 80 scripts there were at least one instance of
"camelCase" naming prior to this commit.

This commit improves consistency in the Python code base by making sure that
these nine remaining files follow the variable naming convention used for
Python code in the project.

References:
* PEP 8: https://www.python.org/dev/peps/pep-0008/
* pep8-naming: https://pypi.python.org/pypi/pep8-naming
2016-03-02 18:56:47 +01:00
practicalswift
f6d6585ee0 [Python] Improve Python consistency: Use function_name(…) throughout (PEP8) 2016-02-29 22:49:19 +01:00
Erik Eckstein
05f864ec26 cmpcodesize: tabs -> spaces 2016-02-29 10:30:41 -08:00
Erik Eckstein
3bc98e0d83 cmpcodesize: fix output of functions which are only in one of the compared files 2016-02-29 10:30:41 -08:00
eeckstein
3f43950f82 Merge pull request #651 from modocache/cmpcodesize-list-functions-early-return
[cmpcodesize] Fix early return in --list
2016-02-26 14:30:41 -08:00
practicalswift
d8a7c4b447 [Python] Argument names should be lowercase by convention 2016-02-20 23:29:41 +01:00
Erik Eckstein
91e36c9574 utils: adapt cmpcodesize to the new benchmark executable names 2016-02-10 12:14:23 -08:00
practicalswift
33452564f6 PEP8: Fix violations of type "continuation line under-indented for hanging indent" (E121) 2016-01-24 09:47:53 +01:00
practicalswift
1cd4d4e9c9 [gardening] Fix violations of non-controversial PEP8 rules
Fixes:
* multiple statements on one line (colon) (E701)
* missing whitespace around arithmetic operator (E226)
* missing whitespace around operator (E225)
* closing bracket does not match visual indentation (E124)
* blank line contains whitespace (W293)
* continuation line missing indentation or outdented (E122)
* continuation line over-indented for hanging indent (E126)
* missing expected blank line (E301)
* trailing whitespace (W291)
* unexpected spaces around keyword / parameter equals (E251)
* whitespace after '(', '[' or '{' (E201)
* whitespace before ')', ']' or '}' (E202)
* whitespace before ',' or ':' (E203)
2016-01-23 09:23:33 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Brian Gesiak
e7184aaac5 [cmpcodesize] Add code headers
Add code headers missing from the Python files in utils/cmpcodesize, as per
the template from #762.
2015-12-27 15:48:14 -05:00
practicalswift
ce760cff66 Fix typos. 2015-12-26 12:43:52 +01:00
practicalswift
a8cabe6cbf Use explicit imports. 2015-12-24 00:19:30 +01:00
practicalswift
4f2496e1a6 Various Python cleanups
Fixes:
* Unused import
* Redundant backslash
* Use of discouraged if not x in y
* Use of deprecated form of raising exceptions

Follow-up to PR #655 as requested by @gribozavr
2015-12-22 21:05:47 +01:00
ken0nek
bdef27268f Fix "== None" and "!= None" 2015-12-21 14:38:58 +09:00
Brian Gesiak
9b655ea0af [cmpcodesize] Fix early return in --list
Fixes a bug, introduced in a1f6040c83,
in which `cmpcodesize -l /path/to/file` would only output the *first* label,
instead of listing all of them.
2015-12-20 23:56:54 -05:00
Alex Chan
ce7ce98a01 Update Python build scripts to use the print function
In Python 3, 'print' was changed from a statement to a function.  Using
the __future__ module allows scripts to use print function whether
running with Python 2.6+ or Python 3.x.  This commit changes as many
instances of print as I could find to use the print function and the
__future__ module.
2015-12-18 23:00:55 +00:00
Brian Gesiak
a1f6040c83 [cmpcodesize] Add some tests for listFunctionSizes
Add unit tests to cmpcodesize. As a basic starting point for unit
tests, add some tests for edge cases in listFunctionSizes.

Users may now run the unit tests for cmpcodesize by running
`python utils/cmpcodesize/setup.py test`.
2015-12-16 18:56:43 -05:00
Brian Gesiak
307c1d98fc [cmpcodesize] Use setuptools for installation
By adding a setup.py file, users may install cmpcodesize to their PATH,
by running `python utils/cmpcodesize/setup.py install`.

Should the Swift project choose to do so, this package may also be uploaded
to the Python Package Index (https://pypi.python.org/pypi). Doing so would
allow anyone with an Internet connection to install cmpcodesize by
running `pip install cmpcodesize`.

Setuptools also provides a convenient way to run unit tests (yet to be
added as of this commit).
2015-12-16 18:56:43 -05:00
Brian Gesiak
7932796cce [cmpcodesize] Convert into Python package
Split up cmpcodesize script into a package, with a main.py file that
acts as an entry point to the program. The functions that use otool to
actually determine binary size have been moved into compare.py.

Note that to execute cmpcodesize, you may now run either:

1. `utils/cmpcodesize/cmpcodesize.py`
2. `python utils/cmpcodesize/cmpcodesize/main.py`
2015-12-16 18:56:43 -05:00