This commit is contained in:
Robert Morris 2022-01-24 05:05:16 -05:00
parent ad9f26ced0
commit 46ec1a324f
3 changed files with 16 additions and 10 deletions

View File

@ -16,7 +16,7 @@ LABS=" lab1 lab2a lab2b lab2c lab2d lab3a lab3b lab4a lab4b "
"--exclude=src/main/mr-*" \ "--exclude=src/main/mr-*" \
"--exclude=mrtmp.*" \ "--exclude=mrtmp.*" \
"--exclude=src/main/diff.out" \ "--exclude=src/main/diff.out" \
"--exclude=src/main/mrmaster" \ "--exclude=src/main/mrcoordinator" \
"--exclude=src/main/mrsequential" \ "--exclude=src/main/mrsequential" \
"--exclude=src/main/mrworker" \ "--exclude=src/main/mrworker" \
"--exclude=*.so" \ "--exclude=*.so" \

View File

@ -37,11 +37,17 @@ func (log *OpLog) Read() []porcupine.Operation {
return ops return ops
} }
// to make sure timestamps use the monotonic clock, instead of computing
// absolute timestamps with `time.Now().UnixNano()` (which uses the wall
// clock), we measure time relative to `t0` using `time.Since(t0)`, which uses
// the monotonic clock
var t0 = time.Now()
// get/put/putappend that keep counts // get/put/putappend that keep counts
func Get(cfg *config, ck *Clerk, key string, log *OpLog, cli int) string { func Get(cfg *config, ck *Clerk, key string, log *OpLog, cli int) string {
start := time.Now().UnixNano() start := int64(time.Since(t0))
v := ck.Get(key) v := ck.Get(key)
end := time.Now().UnixNano() end := int64(time.Since(t0))
cfg.op() cfg.op()
if log != nil { if log != nil {
log.Append(porcupine.Operation{ log.Append(porcupine.Operation{
@ -57,9 +63,9 @@ func Get(cfg *config, ck *Clerk, key string, log *OpLog, cli int) string {
} }
func Put(cfg *config, ck *Clerk, key string, value string, log *OpLog, cli int) { func Put(cfg *config, ck *Clerk, key string, value string, log *OpLog, cli int) {
start := time.Now().UnixNano() start := int64(time.Since(t0))
ck.Put(key, value) ck.Put(key, value)
end := time.Now().UnixNano() end := int64(time.Since(t0))
cfg.op() cfg.op()
if log != nil { if log != nil {
log.Append(porcupine.Operation{ log.Append(porcupine.Operation{
@ -73,9 +79,9 @@ func Put(cfg *config, ck *Clerk, key string, value string, log *OpLog, cli int)
} }
func Append(cfg *config, ck *Clerk, key string, value string, log *OpLog, cli int) { func Append(cfg *config, ck *Clerk, key string, value string, log *OpLog, cli int) {
start := time.Now().UnixNano() start := int64(time.Since(t0))
ck.Append(key, value) ck.Append(key, value)
end := time.Now().UnixNano() end := int64(time.Since(t0))
cfg.op() cfg.op()
if log != nil { if log != nil {
log.Append(porcupine.Operation{ log.Append(porcupine.Operation{

View File

@ -7,7 +7,7 @@
# comment this out to run the tests without the Go race detector. # comment this out to run the tests without the Go race detector.
RACE=-race RACE=-race
if [ "$OSTYPE" = "darwin" ] if [[ "$OSTYPE" = "darwin"* ]]
then then
if go version | grep 'go1.17.[012345]' if go version | grep 'go1.17.[012345]'
then then
@ -30,7 +30,7 @@ else
else else
# no timeout command # no timeout command
TIMEOUT= TIMEOUT=
echo '*** Cannot find timeout command; proceeding anyway.' echo '*** Cannot find timeout command; proceeding without timeouts.'
fi fi
fi fi
if [ "$TIMEOUT" != "" ] if [ "$TIMEOUT" != "" ]
@ -233,7 +233,7 @@ sleep 1
# `jobs` ensures that any completed old processes from other tests # `jobs` ensures that any completed old processes from other tests
# are not waited upon. # are not waited upon.
jobs &> /dev/null jobs &> /dev/null
if [ "$OSTYPE" = "darwin" ] if [[ "$OSTYPE" = "darwin"* ]]
then then
# bash on the Mac doesn't have wait -n # bash on the Mac doesn't have wait -n
while [ ! -e $DF ] while [ ! -e $DF ]