-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: iipeace <[email protected]>
- Loading branch information
Showing
1 changed file
with
41 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
__credits__ = "Peace Lee" | ||
__license__ = "GPLv2" | ||
__version__ = "3.9.8" | ||
__revision__ = "231101" | ||
__revision__ = "231102" | ||
__maintainer__ = "Peace Lee" | ||
__email__ = "[email protected]" | ||
__repository__ = "https://github.com/iipeace/guider" | ||
|
@@ -40879,6 +40879,10 @@ def _getDesc(s, t=0): | |
# {0:1} {1:1} write:TEST | ||
# {0:1} {1:1} -g write:TEST | ||
|
||
- Read specific files infinitely with printing elapsed time | ||
# {0:1} {1:1} "read:TEST1,TEST2" -R -q ELAPSED:0 | ||
# {0:1} {1:1} "read:TEST1,TEST2" -R -q ELAPSED:0.1 | ||
|
||
- Write 100MB of dummy data to the specific file | ||
# {0:1} {1:1} write:TEST:100M | ||
# {0:1} {1:1} "write:TEST:100M, write:TEST2:50M" | ||
|
@@ -63329,17 +63333,37 @@ def _flushCache(verb=False): | |
SysMgr.dropCaches("3", verb) | ||
|
||
def _iotask(num, load): | ||
def _readChunk(fobj, chunk=4096, sync=False): | ||
def _readChunk(fobj, chunk=4096, sync=False, elapsed=False): | ||
while 1: | ||
if elapsed != -1: | ||
prev = time.time() | ||
|
||
ret = os.read(fobj, chunk) | ||
|
||
if elapsed != -1: | ||
diff = time.time() - prev | ||
if diff >= elapsed: | ||
SysMgr.printWarn("elapsed %.3f" % (diff), True) | ||
|
||
yield ret | ||
|
||
def _writeChunk(fobj, chunk=4096, sync=False): | ||
def _writeChunk(fobj, chunk=4096, sync=False, elapsed=False): | ||
while 1: | ||
chunkData = _getChunk() | ||
|
||
if elapsed != -1: | ||
prev = time.time() | ||
|
||
ret = os.write(fobj, chunkData[:chunk]) | ||
|
||
if sync: | ||
os.fsync(fobj) | ||
|
||
if elapsed != -1: | ||
diff = time.time() - prev | ||
if diff >= elapsed: | ||
SysMgr.printWarn("elapsed %.3f" % (diff), True) | ||
|
||
yield ret | ||
|
||
# set default signal handlers # | ||
|
@@ -63363,6 +63387,9 @@ def _writeChunk(fobj, chunk=4096, sync=False): | |
|
||
# get progress value # | ||
printProgress = "PROGRESS" in SysMgr.environList | ||
printElapsed = UtilMgr.getEnvironNum( | ||
"ELAPSED", False, -1, False, isFloat=True | ||
) | ||
|
||
# get data format # | ||
if "RAND" in SysMgr.environList: | ||
|
@@ -63393,6 +63420,9 @@ def _writeChunk(fobj, chunk=4096, sync=False): | |
SysMgr.printErr("failed to recognize '%s'" % path) | ||
sys.exit(-1) | ||
|
||
# declare shortcut function # | ||
conv = UtilMgr.convNum | ||
|
||
for path in pathList: | ||
# check I/O type # | ||
if os.path.isfile(path) or SysMgr.isBlkDev(path): | ||
|
@@ -63420,9 +63450,6 @@ def _writeChunk(fobj, chunk=4096, sync=False): | |
# get output size # | ||
fsize = UtilMgr.getFileSizeStr(path) | ||
|
||
# declare shortcut function # | ||
conv = UtilMgr.convNum | ||
|
||
# make load string # | ||
if size > 0: | ||
loadStr = "only %s " % UtilMgr.convSize2Unit(size) | ||
|
@@ -63497,7 +63524,7 @@ def _writeChunk(fobj, chunk=4096, sync=False): | |
|
||
done = 0 | ||
fd = os.open(path, flag) | ||
for piece in opFunc(fd, chunk, sync): | ||
for piece in opFunc(fd, chunk, sync, printElapsed): | ||
# update progress # | ||
if isinstance(piece, (int, long)): | ||
done += piece | ||
|
@@ -63543,7 +63570,9 @@ def _writeChunk(fobj, chunk=4096, sync=False): | |
|
||
# execute io job # | ||
fd = os.open(fpath, flag) | ||
for piece in opFunc(fd, chunk, sync): | ||
for piece in opFunc( | ||
fd, chunk, sync, printElapsed | ||
): | ||
if not piece: | ||
break | ||
os.close(fd) | ||
|
@@ -88146,7 +88175,10 @@ def getRet(self, temp=False): | |
else: | ||
ret = getattr(self.regs, self.retreg) | ||
|
||
return c_long(ret).value | ||
if c_int(ret).value == -1: | ||
return -1 | ||
else: | ||
return c_long(ret).value | ||
except SystemExit: | ||
sys.exit(0) | ||
except: | ||
|