1#!/usr/bin/env bash
2# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3# Script to report lite build binary size for latest RocksDB commits.
4# Usage:
5#   ./report_lite_binary_size [num_recent_commits]
6
7num_recent_commits=${1:-10}
8
9echo "Computing RocksDB lite build binary size for the most recent $num_recent_commits commits."
10
11for ((i=0; i < num_recent_commits; i++))
12do
13  git checkout master~$i
14  commit_hash=$(git show -s --format=%H)
15  commit_time=$(git show -s --format=%ct)
16
17  # It would be nice to check if scuba already have a record for the commit,
18  # but sandcastle don't seems to have scuba CLI installed.
19
20  make clean
21  make OPT=-DROCKSDB_LITE static_lib
22
23  if make OPT=-DROCKSDB_LITE static_lib
24  then
25    build_succeeded='true'
26    strip librocksdb.a
27    binary_size=$(stat -c %s librocksdb.a)
28  else
29    build_succeeded='false'
30    binary_size=0
31  fi
32
33  current_time="\"time\": $(date +%s)"
34  commit_hash="\"hash\": \"$commit_hash\""
35  commit_time="\"commit_time\": $commit_time"
36  build_succeeded="\"build_succeeded\": \"$build_succeeded\""
37  binary_size="\"binary_size\": $binary_size"
38
39  scribe_log="{\"int\":{$current_time, $commit_time, $binary_size}, \"normal\":{$commit_hash, $build_succeeded}}"
40  echo "Logging to scribe: $scribe_log"
41  scribe_cat perfpipe_rocksdb_lite_build "$scribe_log"
42done
43