Last active
September 10, 2018 05:30
-
-
Save kobaken0029/366aecf3c19de2f01f7576cc506cb120 to your computer and use it in GitHub Desktop.
ビルド時間計測スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BUILD_DIR_PATH=~/Documents/Build | |
START_FILE_PATH=$BUILD_DIR_PATH/_start.txt | |
BUILD_FAILURE_DIR_PATH=$BUILD_DIR_PATH/logs/failure | |
#前回のビルド実行開始時間を取得 | |
START=`cat $START_FILE_PATH` | |
# ビルド開始記録を削除 | |
rm $START_FILE_PATH | |
# ビルド終了時間 | |
END=`date "+%s"` | |
# 現在日時 | |
NOW=`date "+%Y-%m%d_%H:%M:%S"` | |
# ビルド実行時間の情報を格納するディレクトリ作成 | |
mkdir -p $BUILD_FAILURE_DIR_PATH/$NOW | |
# ビルド時間を記録 | |
echo $((END-START)) > $BUILD_FAILURE_DIR_PATH/$NOW/result.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BUILD_DIR_PATH=~/Documents/Build | |
START_FILE_PATH=$BUILD_DIR_PATH/_start.txt | |
BUILD_SUCCESS_DIR_PATH=$BUILD_DIR_PATH/logs/success | |
#前回のビルド実行開始時間を取得 | |
START=`cat $START_FILE_PATH` | |
# ビルド開始記録を削除 | |
rm $START_FILE_PATH | |
# ビルド終了時間 | |
END=`date "+%s"` | |
# 現在日時 | |
NOW=`date "+%Y-%m%d_%H:%M:%S"` | |
# ビルド実行時間の情報を格納するディレクトリ作成 | |
mkdir -p $BUILD_SUCCESS_DIR_PATH/$NOW | |
# ビルド時間を記録 | |
echo $((END-START)) > $BUILD_SUCCESS_DIR_PATH/$NOW/result.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ビルド開始時間記録 | |
date "+%s" > ~/Documents/Build/_start.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "date" | |
def read(filename) | |
file = open(filename) | |
result = file.read(100) | |
file.close | |
result | |
end | |
today = Date.today.strftime("%Y-%m%d") | |
file_path = "~/Documents/Build/logs/*/#{today}*/*.txt" | |
buf = `find #{file_path}` | |
array = buf.split("\n") | |
array = array.slice(0...1000) | |
puts "=========================" | |
puts "【本日のビルド】" | |
puts "ビルド回数: #{array.size}回" | |
puts "ビルド時間:" | |
results = array.map {|filename| read(filename).to_i } | |
results.each { |time| puts "#{time}s" } | |
sec = results.reduce(:+) | |
min = (sec/60.0).round(2) | |
hour = (min/60.0).round(2) | |
day = (hour/8.0).round(1) | |
puts "ビルド総時間: #{sec}s #{min}min #{hour}h #{day}day" | |
sec = results.max | |
min = (sec/60.0).round(2) | |
puts "最大ビルド時間: #{sec}s #{min}min" | |
sec = results.min | |
min = (sec/60.0).round(2) | |
puts "最小ビルド時間: #{sec}s #{min}min" | |
puts "=========================" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment