Commit 24702c50 authored by Ilya Prokhorov's avatar Ilya Prokhorov

Start position argument added

parent a018daa7
......@@ -8,10 +8,9 @@ using namespace std;
int main(int argc, char **argv) {
cout << "Slowride v1.0" << endl;
if (argc != 4) {
cout << "Usage: sudo ./slowride [block device] [mb per block] [ms threshold]" << endl;
cout << "Example: sudo ./slowride /dev/sda2 1000 400" << endl;
cout << "Example: sudo ./slowride /dev/sda2 1000 0" << endl;
if (argc != 4 && argc != 5) {
cout << "Usage: sudo ./slowride [block device] [mb per block] [ms threshold] [optional start GB]" << endl;
cout << "Example (100mb/s): sudo ./slowride /dev/sda2 100 1000" << endl;
exit(3);
}
......@@ -24,21 +23,29 @@ int main(int argc, char **argv) {
inputStream.seekg (0, inputStream.end);
auto length = inputStream.tellg();
auto gbs = length / 1024 / 1024 / 1024;
inputStream.seekg (0, inputStream.beg);
cout << "Length: " << gbs << "GB" << endl;
auto bytesBlockSize = 1024;
auto mgBlocksSize = bytesBlockSize * 1024;
auto mgbsPerBlock = 520;
mgbsPerBlock = atoi(argv[2]);
auto mgbsPerBlock = atoi(argv[2]);
auto blockSize = mgBlocksSize * mgbsPerBlock;
auto buffer = new char[blockSize];
auto timeout = atoi(argv[3]);
for (long long int position = 0; position < length; position += blockSize) {
long long int startPosition = 0;
if (argc == 5) {
startPosition = atol(argv[4]) * 1024 * 1024 * 1024;
cout << "Start: " << argv[4] << "GB "<< endl;
}
inputStream.seekg (startPosition, inputStream.beg);
cout << "take it easy" << endl;
for (long long int position = startPosition; position < length; position += blockSize) {
auto nextPosition = position + blockSize;
if (nextPosition > length) {
......@@ -53,7 +60,7 @@ int main(int argc, char **argv) {
auto end = std::chrono::steady_clock::now();
if (inputStream.gcount() != blockSize) {
auto currentGB = position / 1024 / 1024 / 1000;
auto currentGB = position / 1024 / 1024 / 1024;
cout << "Can't read at " << currentGB << "GB, bad block?" << endl;
}
......@@ -61,7 +68,7 @@ int main(int argc, char **argv) {
if (readTime > timeout) {
auto currentGB = position / 1024 / 1024 / 1000;
cout << "Read threshold at: " << currentGB << "GB" << endl;
cout << "RT:" << currentGB << "GB" << endl;
cout << "T: " << fixed << readTime << setprecision(5);
cout << "s" << endl;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment