#!/bin/sh## This script generates statistics (build size, speed) for successive# revisions of the code. It checks out git commits one an a time, compiles# various ports to determine their size, and runs pystone on the unix port.# Results are collected in the output file.## Note: you will need to copy this file out of the tools directory before# executing because it does not exist in old revisions of the repository.# check that we are in the root directory of the repositoryif [ ! -d py -o ! -d ports/unix -o ! -d ports/stm32 ]; thenecho "script must be run from root of the repository"exit 1fi# output file for the data; data is appended if file already existsoutput=codestats.dat# utility programsRM=/bin/rmAWK=awkMAKE="make -j2"# these are the binaries that are built; some have 2 or 3 depending on versionbin_unix=ports/unix/micropythonbin_stm32=ports/stm32/build-PYBV10/firmware.elfbin_barearm_1=ports/bare-arm/build/flash.elfbin_barearm_2=ports/bare-arm/build/firmware.elfbin_minimal=ports/minimal/build/firmware.elfbin_cc3200_1=ports/cc3200/build/LAUNCHXL/application.axfbin_cc3200_2=ports/cc3200/build/LAUNCHXL/release/application.axfbin_cc3200_3=ports/cc3200/build/WIPY/release/application.axf# start at zero size; if build fails reuse previous valid sizesize_unix="0"size_stm32="0"size_barearm="0"size_minimal="0"size_cc3200="0"# start at zero pystonespystones="0"# this code runs pystone and averages the resultspystoneavg=/tmp/pystoneavg.pycat > $pystoneavg << EOFimport pystonesamples = [pystone.pystones(300000)[1] for i in range(5)]samples.sort()stones = sum(samples[1:-1]) / (len(samples) - 2) # exclude smallest and largestprint("stones %g" % stones)EOFfunction get_size() {if [ -r 2ドル ]; thensize 2ドル | tail -n1 | $AWK '{print 1ドル}'elseecho 1ドルfi}function get_size2() {if [ -r 2ドル ]; thensize 2ドル | tail -n1 | $AWK '{print 1ドル}'elif [ -r 3ドル ]; thensize 3ドル | tail -n1 | $AWK '{print 1ドル}'elseecho 1ドルfi}function get_size3() {if [ -r 2ドル ]; thensize 2ドル | tail -n1 | $AWK '{print 1ドル}'elif [ -r 3ドル ]; thensize 3ドル | tail -n1 | $AWK '{print 1ドル}'elif [ -r 4ドル ]; thensize 4ドル | tail -n1 | $AWK '{print 1ドル}'elseecho 1ドルfi}# get the last revision in the data file; or start at v1.0 if no fileif [ -r $output ]; thenlast_rev=$(tail -n1 $output | $AWK '{print 1ドル}')elseecho "# hash size_unix size_stm32 size_barearm size_minimal size_cc3200 pystones" > $outputlast_rev="v1.0"fi# get a list of hashes between last revision (exclusive) and masterhashes=$(git log --format=format:"%H" --reverse ${last_rev}..master)#hashes=$(git log --format=format:"%H" --reverse ${last_rev}..master | $AWK '{if (NR % 10 == 0) print 0ドル}') # do every 10th onefor hash in $hashes; do#### checkout the revision ####git checkout $hashif [ $? -ne 0 ]; thenecho "aborting"exit 1fi#### apply patches to get it to build ####if grep -q '#if defined(MP_CLOCKS_PER_SEC) && (MP_CLOCKS_PER_SEC == 1000000) // POSIX' unix/modtime.c; thenecho apply patchgit apply - << EOFdiff --git a/unix/modtime.c b/unix/modtime.cindex 77d2945..dae0644 100644--- a/unix/modtime.c+++ b/unix/modtime.c@@ -55,10 +55,8 @@ void msec_sleep_tv(struct timeval *tv) {#define MP_CLOCKS_PER_SEC CLOCKS_PER_SEC#endif-#if defined(MP_CLOCKS_PER_SEC) && (MP_CLOCKS_PER_SEC == 1000000) // POSIX-#define CLOCK_DIV 1000.0-#elif defined(MP_CLOCKS_PER_SEC) && (MP_CLOCKS_PER_SEC == 1000) // WIN32-#define CLOCK_DIV 1.0+#if defined(MP_CLOCKS_PER_SEC)+#define CLOCK_DIV (MP_CLOCKS_PER_SEC / 1000.0F)#else#error Unsupported clock() implementation#endifEOFfi#### unix ####$RM $bin_unix$MAKE -C ports/unix CFLAGS_EXTRA=-DNDEBUGsize_unix=$(get_size $size_unix $bin_unix)# undo patch if it was appliedgit checkout unix/modtime.c#### stm32 ####$RM $bin_stm32$MAKE -C ports/stm32 board=PYBV10size_stm32=$(get_size $size_stm32 $bin_stm32)#### bare-arm ####$RM $bin_barearm_1 $bin_barearm_2$MAKE -C ports/bare-armsize_barearm=$(get_size2 $size_barearm $bin_barearm_1 $bin_barearm_2)#### minimal ####if [ -r ports/minimal/Makefile ]; then$RM $bin_minimal$MAKE -C ports/minimal CROSS=1size_minimal=$(get_size $size_minimal $bin_minimal)fi#### cc3200 ####if [ -r ports/cc3200/Makefile ]; then$RM $bin_cc3200_1 $bin_cc3200_2 $bin_cc3200_3$MAKE -C ports/cc3200 BTARGET=applicationsize_cc3200=$(get_size3 $size_cc3200 $bin_cc3200_1 $bin_cc3200_2 $bin_cc3200_3)fi#### run pystone ####if [ -x $bin_unix ]; thennew_pystones=$($bin_unix $pystoneavg)# only update the variable if pystone executed successfullyif echo $new_pystones | grep -q "^stones"; thenpystones=$(echo $new_pystones | $AWK '{print 2ドル}')fifi#### output data for this commit ####echo "$hash$size_unix$size_stm32$size_barearm$size_minimal$size_cc3200$pystones" >> $outputdone# checkout master and cleanupgit checkout master$RM $pystoneavg
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。