맥의 하드용량이 내가 파일을 하드에 저장하는 것을 인지하는 것 보다 더 빨리 줄어드는 것 같다. 그래서 Hazel 에 규칙을 만들어서 주기적으로 안쓰는 파일을 지우거나 외장하드에 백업하기도 한다.
최근에는 맥북의 SSD에 16GB정도가 남아 있었는데, spotlight 인덱싱 때문인지 임시적으로 0이 될때도 있어서, 몇일 전에는 애플메일에는 spotlight 인덱싱을 뺐더니 하드확보는 되는 것 같다. magican으로 임시파일들을 청소하기도하고, Hazel 규칙을 만들어서 청소하기도 한다.
근데 오늘 뜻하지 않게 약 70GB를 확보하게 되었다.
결론 부터 얘기하면, Xcode 가 빌드할때 마다 아카이브하고 있는 파일들을 청소해서이다.
Xcode 프로젝트에서 기존에 있던 파일명으로 새로 파일을 만들고나서 빌드 오류가 나서 해결책을 찾다가 ~/Library/Developer/Xcode/DerivedData directory 라는 것을 발견했는데, 여기게 62GB가 있었다.
1. ~/Library/Developer/Xcode/DerivedData 지우기
찾아보니 이 디렉토리에 프로젝트 별로 빌드에 관한 정보가 다 저장되어 있다고 한다. 그래서 프로젝트 인덱싱이 잘 안되면 이 디렉토리를 지우는 것이 좋다는 팁도 있는데, 이게 계속 쌓이기만 하고 있는 것이 문제인 것 같다. 이 디렉토리를 지우고 다시 빌드를 하면 다시 생기니 여러 프로젝트를 하는 경우에 이 디렉토리를 지워도 되는 것 같다.
이 디렉토리르 지워서 62GB 가 생겼다.
2. ~/Library/Developer/Xcode/Archives 지우기
찾은 김에 Xcode 디렉토리들을 하나씩 봤는데, Archives 디렉토리도 있었다. 이건 릴리즈한 것에 대해서 디버깅을 할 수 있는 정보들이 있었다. 이것도 Xcode 에서 archive 할때마다 쌓이는 모양이다. 이 디렉토리는 지워서 8GB를 얻었다.
3. ~/Library/Developer/Xcode/iOS Device Logs 지우기
여기에 560MB 가 있었고, 로그를 볼일이 없어서 지웠다.
4. ~/Library/Developer/Xcode/ iOS DeviceSupport 필요 없는 시뮬레이터 지우기
여기에 8.64 GB 가 있었는데, 보니 iOS 5 부터 시뮬레이터들이 있었다. 최근것 남기도 다 지웠다.
Xcode 디렉토리들을 지워서 약 70GB를 확보 했다. 256 GB SSD 에서 70GB는 겁나 큰 수확이었다.
DerivedData directory 는 빌드할때 문제가 있을때 지우고 해보거나 하는 식의 팁들이 있었지만, 내 경우에는 하드용량을 확보하기 위해서 지우게된 셈이다.
매번 볼수는 없으니 Hazel 로 이 빌드 폴더가 5 기가 이상이 되면 자동으로 지워지게 규칙을 만들었다.
혹시 Xcode 를 사용하는 분 중에서 하드용량 확보 필요가 있다면 ~/Library/Developer/Xcode/ 디렉토리 용량이 얼마나 되는지 확인한번 해보는 것도 좋을 것같다.
TimeSpan time = TimeSpan.FromSeconds(seconds);
//here backslash is must to tell that colon is
//not the part of format, it just a character that we want in output
string str = time .ToString(@"hh\:mm\:ss\:fff");
private string ConvertTime(double miliSeconds)
{
var timeSpan = TimeSpan.FromMilliseconds(totalMiliSeconds);
// Converts the total miliseconds to the human readable time format
return timeSpan.ToString(@"hh\:mm\:ss\:fff");
}
//테스트
[TestCase(1002, "00:00:01:002")]
[TestCase(700011, "00:11:40:011")]
[TestCase(113879834, "07:37:59:834")]
public void ConvertTime_ResturnsCorrectString(double totalMiliSeconds, string expectedMessage)
{
// Arrange
var obj = new Class();;
// Act
var resultMessage = obj.ConvertTime(totalMiliSeconds);
// Assert
Assert.AreEqual(expectedMessage, resultMessage);
}
VB.NET에서는 C #과 동일합니다.
Dim x As New TimeSpan(0, 0, 80)
debug.print(x.ToString())
' Will print 00:01:20
가장 빠른 방법을 알기 위해 몇 가지 벤치 마크를 수행했으며 이는 내 결과 및 결론입니다. 각 방법을 10M 번 실행하고 실행 당 평균 시간을 주석을 추가했습니다.
입력 된 밀리 초가 1 일로 제한되지 않으면 (결과는 143 : 59 : 59.999 일 수 있음) 다음과 같은 옵션이 있습니다.
// 0.86 ms
static string Method1(int millisecs)
{
int hours = millisecs / 3600000;
int mins = (millisecs % 3600000) / 60000;
// Make sure you use the appropriate decimal separator
return string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", hours, mins, millisecs % 60000 / 1000, millisecs % 1000);
}
// 0.89 ms
static string Method2(int millisecs)
{
double s = millisecs % 60000 / 1000.0;
millisecs /= 60000;
int mins = millisecs % 60;
int hours = millisecs / 60;
return string.Format("{0:D2}:{1:D2}:{2:00.000}", hours, mins, s);
}
// 0.95 ms
static string Method3(int millisecs)
{
TimeSpan t = TimeSpan.FromMilliseconds(millisecs);
// Make sure you use the appropriate decimal separator
return string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}",
(int)t.TotalHours,
t.Minutes,
t.Seconds,
t.Milliseconds);
}
입력 된 밀리 초가 1 일로 제한되는 경우 (결과가 23 : 59 : 59.999보다 클 수 없습니다) 이러한 옵션은 더 빠르거나 느릴 때까지 있습니다.
// 0.58 ms
static string Method5(int millisecs)
{
// Fastest way to create a DateTime at midnight
// Make sure you use the appropriate decimal separator
return DateTime.FromBinary(599266080000000000).AddMilliseconds(millisecs).ToString("HH:mm:ss.fff");
}
// 0.59 ms
static string Method4(int millisecs)
{
// Make sure you use the appropriate decimal separator
return TimeSpan.FromMilliseconds(millisecs).ToString(@"hh\:mm\:ss\.fff");
}
// 0.93 ms
static string Method6(int millisecs)
{
TimeSpan t = TimeSpan.FromMilliseconds(millisecs);
// Make sure you use the appropriate decimal separator
return string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}",
t.Hours,
t.Minutes,
t.Seconds,
t.Milliseconds);
}
입력이 불과 몇 초일 경우, 메소드가 약간 더 빠릅니다. 다시 말하지만, 입력 초가 1 일로 제한되지 않으면 결과가 143 : 59 : 59 일 수 있습니다.
// 0.63 ms
static string Method1(int secs)
{
int hours = secs / 3600;
int mins = (secs % 3600) / 60;
secs = secs % 60;
return string.Format("{0:D2}:{1:D2}:{2:D2}", hours, mins, secs);
}
// 0.64 ms
static string Method2(int secs)
{
int s = secs % 60;
secs /= 60;
int mins = secs % 60;
int hours = secs / 60;
return string.Format("{0:D2}:{1:D2}:{2:D2}", hours, mins, s);
}
// 0.70 ms
static string Method3(int secs)
{
TimeSpan t = TimeSpan.FromSeconds(secs);
return string.Format("{0:D2}:{1:D2}:{2:D2}",
(int)t.TotalHours,
t.Minutes,
t.Seconds);
}
그리고 입력 한 초가 1 일로 제한되는 경우 (결과는 결코 23:59:59보다 클 수 없습니다) :
// 0.33 ms
static string Method5(int secs)
{
// Fastest way to create a DateTime at midnight
return DateTime.FromBinary(599266080000000000).AddSeconds(secs).ToString("HH:mm:ss");
}
// 0.34 ms
static string Method4(int secs)
{
return TimeSpan.FromSeconds(secs).ToString(@"hh\:mm\:ss");
}
// 0.70 ms
static string Method6(int secs)
{
TimeSpan t = TimeSpan.FromSeconds(secs);
return string.Format("{0:D2}:{1:D2}:{2:D2}",
t.Hours,
t.Minutes,
t.Seconds);
}
마지막 의견으로, string.Format 가 00 대신 D2 를 사용하면 조금 더 빠르다는 것을 알았습니다.