Commit Graph

66 Commits

Author SHA1 Message Date
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
Brian Gesiak
34c9c2c196 [cmpcodesize] Move script into dir to package-ify
The cmpcodesize script is a little unwieldy--the same file contains
command-line argument parsing, otool invocation, and result
output formatting.

To split the script into several files, we'll need to turn it into a
Python package. In order to do so, we first move it into its own
directory.

Note that to invoke the script, you'll now need to run
`utils/cmpcodesize/cmpcodesize`. That additional path component is
inconvenient for now, but things will get better soon.
2015-12-16 18:56:43 -05:00
Brian Gesiak
954f109e30 [cmpcodesize] Use join instead of Unix separator
Use `os.path.join` instead of using Unix file separator--just in case
this is run on other platforms some day.
2015-12-16 18:56:42 -05:00
Brian Gesiak
0aaeca1de9 [cmpcodesize] Reuse shortcuts as global constant
Two parts of the code reference the shorthand for specified PerfTests_*
directories. Promote them to a constant and reuse them.
2015-12-16 18:56:42 -05:00
Brian Gesiak
9c3c25e39c [cmpcodesize] Assert env vars set properly
`$SWIFT_OLD_BUILDDIR` and `$SWIFT_NEW_BUILDDIR` are only necessary when
not using `--` to delineate two sets of files.

1. Only grab them from the environment when `--` is *not* used.
2. Assert if they're not present in that codepath. Print what *is*
   specified in the environment, in order to help the user correct
   their mistake.
2015-12-16 18:56:42 -05:00
Brian Gesiak
9e951f524a [cmpcodesize] Assert early for bad use of --list
We can detect improper use of --list very early in the script's
execution. Favor doing so to warn the user earlier. Also, add
documentation for proper use of --list.
2015-12-16 18:56:17 -05:00
Brian Gesiak
8d7e7c7288 [cmpcodesize] Remove superfluous variables
The values are already stored on the parsed arguments, so remove the
variables and clear up the variable namespace a little.

Also, use snake_case, which is more Pythonic. This commit doesn't
change all variable names in the interest of keeping changes minimal.
2015-12-16 18:56:16 -05:00
Brian Gesiak
02fb3ea264 [cmpcodesize] Assert improper use of --list
We can detect improper combinations of --list and
--additional-sections/--category very soon when executing the script.
Assert in those cases. This used to be a warning.
2015-12-16 18:56:16 -05:00
Brian Gesiak
95f22eddcb [cmpcodesize] Use Python indices for separator
Because of the way Python uses references for lists, the logic around
`oldFileArgs`, `newFileArgs`, and `curFiles` is difficult to follow.
Use a less efficient algorithm to find and split the elements based on
the '--' separator.

Although its performance is negligibly worse O(2n) as opposed to O(n), it's
easier to understand and uses one less imperative loop. Also, it's not as if
we'll ever encounter input that makes the performance difference
matter, so :shipit:!
2015-12-16 18:56:16 -05:00
Brian Gesiak
75bf127431 [cmpcodesize] Use argparse
Rather than manually parse the arguments passed to cmpcodesize, use the
Python stdlib. By doing so, we can eliminate a lot of redundant code.

One problem: argparse can't handle positional arguments of the string
'--', since it misinterprets them as optional arguments. We replace
that stirng with a special token.
2015-12-16 18:56:16 -05:00