Commit 4f2168a
committed
class-version.sh: avoid using javap
Just for you, Dscho!
Unfortunately, and surprisingly, performance is not much better:
export jar1=org/python/jython-standalone/2.7-b3/jython-standalone-2.7-b3.jar
export jar2=org/python/jython-standalone/2.5.3/jython-standalone-2.5.3.jar
== Using javap ==
$ time class-version.sh $jar1 $jar2
org/python/jython-standalone/2.7-b3/jython-standalone-2.7-b3.jar: J2SE 7 (51.0)
org/python/jython-standalone/2.5.3/jython-standalone-2.5.3.jar: J2SE 5.0 (49.0)
real 0m2.538s
user 0m4.616s
sys 0m0.810s
$ time class-version.sh $jar1 $jar2
org/python/jython-standalone/2.7-b3/jython-standalone-2.7-b3.jar: J2SE 7 (51.0)
org/python/jython-standalone/2.5.3/jython-standalone-2.5.3.jar: J2SE 5.0 (49.0)
real 0m2.382s
user 0m4.467s
sys 0m0.786s
== Using unzip ==
$ time class-version.sh $jar1 $jar2
org/python/jython-standalone/2.7-b3/jython-standalone-2.7-b3.jar: J2SE 7 (51.0)
org/python/jython-standalone/2.5.3/jython-standalone-2.5.3.jar: J2SE 5.0 (49.0)
real 0m3.026s
user 0m4.443s
sys 0m1.158s
$ time class-version.sh $jar1 $jar2
org/python/jython-standalone/2.7-b3/jython-standalone-2.7-b3.jar: J2SE 7 (51.0)
org/python/jython-standalone/2.5.3/jython-standalone-2.5.3.jar: J2SE 5.0 (49.0)
real 0m3.061s
user 0m4.486s
sys 0m1.161s
== Simplifying further ==
Even if you cut out the sed and expr commands like so:
# extract byte #7
major="$(unzip -p "$jar" "$(jar tf "$jar" | grep \.class$ | head -n 1)" | head -c 8 | hexdump -s 7 -e '1/1 "%d\n"')"
The results are no more impressive:
$ time class-version.sh $jar1 $jar2
org/python/jython-standalone/2.7-b3/jython-standalone-2.7-b3.jar: J2SE 7 (51)
org/python/jython-standalone/2.5.3/jython-standalone-2.5.3.jar: J2SE 5.0 (49)
real 0m3.053s
user 0m4.526s
sys 0m1.151s
$ time class-version.sh $jar1 $jar2
org/python/jython-standalone/2.7-b3/jython-standalone-2.7-b3.jar: J2SE 7 (51)
org/python/jython-standalone/2.5.3/jython-standalone-2.5.3.jar: J2SE 5.0 (49)
real 0m3.063s
user 0m4.656s
sys 0m1.151s1 parent e3a6f97 commit 4f2168a
1 file changed
Lines changed: 12 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | | - | |
12 | | - | |
13 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
14 | 22 | | |
15 | 23 | | |
16 | 24 | | |
| |||
0 commit comments