Skip to content

Commit

Permalink
Print out the N and seed value. Also use Map instead of HashMap and a…
Browse files Browse the repository at this point in the history
…dd copyright.
  • Loading branch information
luqmana committed Jun 8, 2016
1 parent 13776b8 commit 7f2f14b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

By adding your name to this document, you agree to release all your contributions to Flix under the [Apache 2.0 License](LICENSE.md).

- [Luqman Aden](https://github.com/luqmana)
- [Magnus Madsen](https://github.com/magnus-madsen) ([website](http://plg.uwaterloo.ca/~mmadsen/))
- [Ming-Ho Yee](https://github.com/mhyee) ([website](http://mhyee.com))

29 changes: 25 additions & 4 deletions main/test/ca/uwaterloo/flix/util/perf/RandomLatticeGraph.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2016 Luqman Aden
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package ca.uwaterloo.flix.util.perf

import scala.collection.immutable.HashMap
Expand All @@ -10,7 +26,7 @@ object RandomLatticeGraph {

def main(args: Array[String]): Unit = {

val lattices = HashMap(
val lattices = Map(
"Belnap" -> Lattice(
"Belnap",
Array("Top", "True", "False", "Bot"),
Expand Down Expand Up @@ -102,11 +118,13 @@ object RandomLatticeGraph {

val which = args(0).toString
val N = args(1).toInt
val rng = if (args.length == 3) {
new Random(args(2).toLong)
val seed = if (args.length == 3) {
args(2).toLong
} else {
new Random()
// We generate one here so that we can print out a seed value even if the user hasn't specified one
Random.nextLong()
}
val rng = new Random(seed)

val lattice = lattices get which match {
case Some(l) => l
Expand All @@ -116,6 +134,9 @@ object RandomLatticeGraph {
}
}

println(s"// N: $N")
println(s"// seed: $seed")

// Create a list of N values, each assigned a random from our lattice
val values: Array[String] = Seq.fill(N) {
lattice.els(rng.nextInt(lattice.els.length))
Expand Down

0 comments on commit 7f2f14b

Please sign in to comment.