HADOOP-14881. LoadGenerator should use Time.monotonicNow() to measure durations. Contributed by Bharat Viswanadham
This commit is contained in:
parent
e928ee583c
commit
ac05a51bbb
@ -277,9 +277,9 @@ private void nextOp() throws IOException {
|
|||||||
* the entire file */
|
* the entire file */
|
||||||
private void read() throws IOException {
|
private void read() throws IOException {
|
||||||
String fileName = files.get(r.nextInt(files.size()));
|
String fileName = files.get(r.nextInt(files.size()));
|
||||||
long startTime = Time.now();
|
long startTimestamp = Time.monotonicNow();
|
||||||
InputStream in = fc.open(new Path(fileName));
|
InputStream in = fc.open(new Path(fileName));
|
||||||
executionTime[OPEN] += (Time.now()-startTime);
|
executionTime[OPEN] += (Time.monotonicNow() - startTimestamp);
|
||||||
totalNumOfOps[OPEN]++;
|
totalNumOfOps[OPEN]++;
|
||||||
while (in.read(buffer) != -1) {}
|
while (in.read(buffer) != -1) {}
|
||||||
in.close();
|
in.close();
|
||||||
@ -299,9 +299,9 @@ private void write() throws IOException {
|
|||||||
double fileSize = 0;
|
double fileSize = 0;
|
||||||
while ((fileSize = r.nextGaussian()+2)<=0) {}
|
while ((fileSize = r.nextGaussian()+2)<=0) {}
|
||||||
genFile(file, (long)(fileSize*BLOCK_SIZE));
|
genFile(file, (long)(fileSize*BLOCK_SIZE));
|
||||||
long startTime = Time.now();
|
long startTimestamp = Time.monotonicNow();
|
||||||
fc.delete(file, true);
|
fc.delete(file, true);
|
||||||
executionTime[DELETE] += (Time.now()-startTime);
|
executionTime[DELETE] += (Time.monotonicNow() - startTimestamp);
|
||||||
totalNumOfOps[DELETE]++;
|
totalNumOfOps[DELETE]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,9 +310,9 @@ private void write() throws IOException {
|
|||||||
*/
|
*/
|
||||||
private void list() throws IOException {
|
private void list() throws IOException {
|
||||||
String dirName = dirs.get(r.nextInt(dirs.size()));
|
String dirName = dirs.get(r.nextInt(dirs.size()));
|
||||||
long startTime = Time.now();
|
long startTimestamp = Time.monotonicNow();
|
||||||
fc.listStatus(new Path(dirName));
|
fc.listStatus(new Path(dirName));
|
||||||
executionTime[LIST] += (Time.now()-startTime);
|
executionTime[LIST] += (Time.monotonicNow() - startTimestamp);
|
||||||
totalNumOfOps[LIST]++;
|
totalNumOfOps[LIST]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,14 +320,14 @@ private void list() throws IOException {
|
|||||||
* The file is filled with 'a'.
|
* The file is filled with 'a'.
|
||||||
*/
|
*/
|
||||||
private void genFile(Path file, long fileSize) throws IOException {
|
private void genFile(Path file, long fileSize) throws IOException {
|
||||||
long startTime = Time.now();
|
long startTimestamp = Time.monotonicNow();
|
||||||
FSDataOutputStream out = null;
|
FSDataOutputStream out = null;
|
||||||
try {
|
try {
|
||||||
out = fc.create(file,
|
out = fc.create(file,
|
||||||
EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE),
|
EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE),
|
||||||
CreateOpts.createParent(), CreateOpts.bufferSize(4096),
|
CreateOpts.createParent(), CreateOpts.bufferSize(4096),
|
||||||
CreateOpts.repFac((short) 3));
|
CreateOpts.repFac((short) 3));
|
||||||
executionTime[CREATE] += (Time.now() - startTime);
|
executionTime[CREATE] += (Time.monotonicNow() - startTimestamp);
|
||||||
numOfOps[CREATE]++;
|
numOfOps[CREATE]++;
|
||||||
|
|
||||||
long i = fileSize;
|
long i = fileSize;
|
||||||
@ -337,8 +337,8 @@ private void genFile(Path file, long fileSize) throws IOException {
|
|||||||
i -= s;
|
i -= s;
|
||||||
}
|
}
|
||||||
|
|
||||||
startTime = Time.now();
|
startTimestamp = Time.monotonicNow();
|
||||||
executionTime[WRITE_CLOSE] += (Time.now() - startTime);
|
executionTime[WRITE_CLOSE] += (Time.monotonicNow() - startTimestamp);
|
||||||
numOfOps[WRITE_CLOSE]++;
|
numOfOps[WRITE_CLOSE]++;
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.cleanupWithLogger(LOG, out);
|
IOUtils.cleanupWithLogger(LOG, out);
|
||||||
|
Loading…
Reference in New Issue
Block a user