xref: /aosp_15_r20/external/cronet/third_party/icu/scripts/diff_data.sh (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1#!/bin/bash
2
3# set -x
4
5ICUROOT="$(dirname "$0")/.."
6
7if [ $# -lt 3 ];
8then
9  echo "Usage: "$0" (android|cast|chromeos|common|flutter|flutter_desktop|ios) icubuilddir1 icubuilddir2" >&2
10  echo "$0 compare data files of a particular build inside two icu build directory." >&2
11  echo "These files were previously archived by backup_outdir in scripts/copy_data.sh." >&2
12  echo "The first parameter indicate which build to be compared." >&2
13  exit 1
14fi
15
16# Input Parameters
17BUILD=$1
18DIR1=$2
19DIR2=$3
20
21echo "======================================================="
22echo "                ${BUILD} BUILD REPORT"
23echo "======================================================="
24RESSUBDIR1=`ls ${DIR1}/dataout/${BUILD}/data/out/build`
25RESDIR1="${DIR1}/dataout/${BUILD}/data/out/build/${RESSUBDIR1}"
26ICUDATA_LST1="${DIR1}/dataout/${BUILD}/data/out/tmp/icudata.lst"
27RESSUBDIR2=`ls ${DIR2}/dataout/${BUILD}/data/out/build`
28RESDIR2="${DIR2}/dataout/${BUILD}/data/out/build/${RESSUBDIR2}"
29ICUDATA_LST2="${DIR2}/dataout/${BUILD}/data/out/tmp/icudata.lst"
30SORTED_ICUDATA_LST1=/tmp/${BUILD}1_icudata_lst
31SORTED_ICUDATA_LST2=/tmp/${BUILD}2_icudata_lst
32
33sort ${ICUDATA_LST1} >${SORTED_ICUDATA_LST1}
34sort ${ICUDATA_LST2} >${SORTED_ICUDATA_LST2}
35echo "              ICUDATA.LST DIFFERENCES"
36diff -u ${SORTED_ICUDATA_LST1} ${SORTED_ICUDATA_LST2}
37echo "-------------------------------------------------------"
38
39
40echo -n "> Checking and sorting the diff size ."
41SIZEFILE=/tmp/${BUILD}size.txt
42SIZESORTEDFILE=/tmp/${BUILD}sizesorted.txt
43count=0
44rm -rf $SIZEFILE
45for res in $(cat "${SORTED_ICUDATA_LST2}")
46do
47  # diff the txt file
48  STAT1=`stat --printf="%s" ${RESDIR1}/$res`
49  STAT2=`stat --printf="%s" ${RESDIR2}/$res`
50  SIZEDIFF=`expr $STAT2 - $STAT1`
51  echo $SIZEDIFF $STAT1 $STAT2 $res >> $SIZEFILE
52  count=`expr $count + 1`
53  if [ $count -gt 100 ]
54  then
55    count=0
56    echo -n "."
57  fi
58done
59
60echo "#Increase Old New Res" > $SIZESORTEDFILE
61sort -n $SIZEFILE >>$SIZESORTEDFILE
62
63echo ""
64echo "-------------------------------------------------------"
65echo "              RES SIZE DIFFERENCES"
66cat $SIZESORTEDFILE
67
68exit
69