-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Benchmark/towers #26
Benchmark/towers #26
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be much simplified if you define your types as
type Disk = Int
type Pile = List[Disk]
In this case deviating from the original is warranted.
src/towers.effekt
Outdated
//each list represents one smallerDisk. | ||
//TODO type alias, rename as "smallerDisk" | ||
//smallerDisk.next is the smallerDisk below => kellerstack | ||
type Disk = List[Int] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this to Disks
or Pile
or Stack
. A single disk is an integer (its size).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we sure we want to deviate from the original?
it would change the semantics quite a lot and probably make it less comparable to the JS implementation of the benchmark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, do it. The semantics will stay the same, we are merely using types to enforce preconditions.
src/towers.effekt
Outdated
innerBenchmarkLoop(1){benchmark}{verifyResult} | ||
} | ||
|
||
def diskSize(d: Disk): Int = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is head
on lists. Use this instead.
src/towers.effekt
Outdated
var piles: Array[Disk] = emptyArray(); | ||
var movesDone: Int = 0; | ||
|
||
def pushDisk(piles: Array[Disk], smallerDisk: Disk, pileIdx: Int): Disk = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
smallerDisk
should be an Int
. You could introduce an alias type Disk = Int
.
src/towers.effekt
Outdated
return currentTopDisk | ||
} | ||
|
||
def popDiskFrom(pileIdx: Int): Disk = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one does not abctract over piles
, while pushDisk
does. It should be consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the signatures of popDiskFrom and pushDisk are taken from the javascript benchmarks.
i would prefer to not change them, to stay as true to the original as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The signatures currently are:
def pushDisk(piles: Array[Disk], smallerDisk: Disk, pileIdx: Int): Disk
def popDiskFrom(pileIdx: Int): Disk
Where in the original they are:
pushDisk(disk, pile)
popDiskFrom(pile)
So in Effekt they should be either:
def pushDisk(piles: Array[Disk], smallerDisk: Disk, pileIdx: Int): Disk
def popDiskFrom(piles: Array[Disk], pileIdx: Int): Disk
Or they should be:
def pushDisk(smallerDisk: Disk, pileIdx: Int): Disk
def popDiskFrom(pileIdx: Int): Disk
8c0eab2
to
b5b6f31
Compare
rename field add towers benchmark to runner fix towers benchmark, used list left commented out debug helper stuff in there in case i ever have to touch it again
b5b6f31
to
281b946
Compare
281b946
to
0eed1d9
Compare
0eed1d9
to
4f8671c
Compare
fixes #14