<commit_before>package org.scalameter



import language.implicitConversions
import scala.collection.{Seq, immutable}
import org.scalameter.Key._



case class Context(properties: immutable.Map[Key[_], Any]) {
  def -[T](t: Key[T]) = Context(properties - t)
  def +[T](t: (Key[T], T)) = Context(properties + t)
  def ++(that: Context) = Context(this.properties ++ that.properties)
  def ++(that: Seq[KeyValue]) = Context(this.properties ++ that)
  def get[T](key: Key[T]): Option[T] =
    properties.get(key).asInstanceOf[Option[T]].orElse {
      key match {
        case k: KeyWithDefaultValue[_] => Some(k.default.asInstanceOf[T])
        case _ => None
      }
    }
  def goe[T](key: Key[T], v: => T) = properties.getOrElse(key, v).asInstanceOf[T]
  def apply[T](key: KeyWithDefault[T]) = {
    val value = key match {
      case k: KeyWithDefaultKey[_] =>
        properties.getOrElse(key, properties.getOrElse(k.default, k.default.default))
      case k: KeyWithDefaultValue[_] =>
        properties.getOrElse(k, k.default)
    }
    value.asInstanceOf[T]
  }
  def scope = scopeList.mkString(".")
  def scopeList = apply(dsl.scope).reverse
  def curve = apply(dsl.curve)
  def unit = goe(gen.unit, "")
  override def toString = {
    val proplines = properties.map {
      case (key, value) => s"$key -> $value"
    } mkString("\n")
    s"Context(\n$proplines\n)"
  }
}


object Context {
  def apply(xs: KeyValue*) = new Context(xs.asInstanceOf[Seq[(Key[_], Any)]].toMap)

  val empty = new Context(immutable.Map.empty)

  val topLevel = machine ++ Context(
    preJDK7 -> false,
    dsl.scope -> Nil,
    exec.benchRuns -> 36,
    exec.minWarmupRuns -> 10,
    exec.maxWarmupRuns -> 50,
    exec.jvmflags -> List("-Xmx2048m", "-Xms2048m", "-XX:CompileThreshold=100"),
    classpath -> utils.ClassPath.default,
    reports.regression.significance -> 1e-10,
    verbose -> false
  )

  val inlineBenchmarking = machine ++ Context(
    exec.benchRuns -> 1,
    exec.minWarmupRuns -> 10,
    exec.maxWarmupRuns -> 50,
    exec.requireGC -> false,
    verbose -> false
  )

  def machine = Context(
    Key.machine.jvm.version -> sys.props("java.vm.version"),
    Key.machine.jvm.vendor -> sys.props("java.vm.vendor"),
    Key.machine.jvm.name -> sys.props("java.vm.name"),
    Key.machine.osName -> sys.props("os.name"),
    Key.machine.osArch -> sys.props("os.arch"),
    Key.machine.cores -> Runtime.getRuntime.availableProcessors,
    Key.machine.hostname -> java.net.InetAddress.getLocalHost.getHostName
  )

  @deprecated(<commit_msg>Fallback to loopback address if DNS lookup to get hostname fails<commit_after>package org.scalameter



import language.implicitConversions
import scala.collection.{Seq, immutable}
import org.scalameter.Key._



case class Context(properties: immutable.Map[Key[_], Any]) {
  def -[T](t: Key[T]) = Context(properties - t)
  def +[T](t: (Key[T], T)) = Context(properties + t)
  def ++(that: Context) = Context(this.properties ++ that.properties)
  def ++(that: Seq[KeyValue]) = Context(this.properties ++ that)
  def get[T](key: Key[T]): Option[T] =
    properties.get(key).asInstanceOf[Option[T]].orElse {
      key match {
        case k: KeyWithDefaultValue[_] => Some(k.default.asInstanceOf[T])
        case _ => None
      }
    }
  def goe[T](key: Key[T], v: => T) = properties.getOrElse(key, v).asInstanceOf[T]
  def apply[T](key: KeyWithDefault[T]) = {
    val value = key match {
      case k: KeyWithDefaultKey[_] =>
        properties.getOrElse(key, properties.getOrElse(k.default, k.default.default))
      case k: KeyWithDefaultValue[_] =>
        properties.getOrElse(k, k.default)
    }
    value.asInstanceOf[T]
  }
  def scope = scopeList.mkString(".")
  def scopeList = apply(dsl.scope).reverse
  def curve = apply(dsl.curve)
  def unit = goe(gen.unit, "")
  override def toString = {
    val proplines = properties.map {
      case (key, value) => s"$key -> $value"
    } mkString("\n")
    s"Context(\n$proplines\n)"
  }
}


object Context {
  def apply(xs: KeyValue*) = new Context(xs.asInstanceOf[Seq[(Key[_], Any)]].toMap)

  val empty = new Context(immutable.Map.empty)

  val topLevel = machine ++ Context(
    preJDK7 -> false,
    dsl.scope -> Nil,
    exec.benchRuns -> 36,
    exec.minWarmupRuns -> 10,
    exec.maxWarmupRuns -> 50,
    exec.jvmflags -> List("-Xmx2048m", "-Xms2048m", "-XX:CompileThreshold=100"),
    classpath -> utils.ClassPath.default,
    reports.regression.significance -> 1e-10,
    verbose -> false
  )

  val inlineBenchmarking = machine ++ Context(
    exec.benchRuns -> 1,
    exec.minWarmupRuns -> 10,
    exec.maxWarmupRuns -> 50,
    exec.requireGC -> false,
    verbose -> false
  )

  def machine = {
    def hostname = {
      val localAddress = try {
        java.net.InetAddress.getLocalHost
      } catch {
        case _: java.net.UnknownHostException => // DNS lookup failure
          java.net.InetAddress.getLoopbackAddress
      }
      localAddress.getHostName
    }

    Context(
      Key.machine.jvm.version -> sys.props("java.vm.version"),
      Key.machine.jvm.vendor -> sys.props("java.vm.vendor"),
      Key.machine.jvm.name -> sys.props("java.vm.name"),
      Key.machine.osName -> sys.props("os.name"),
      Key.machine.osArch -> sys.props("os.arch"),
      Key.machine.cores -> Runtime.getRuntime.availableProcessors,
      Key.machine.hostname -> hostname
    )
  }

  @deprecated(
{'fraction_non_alphanumeric': 0.15572406140188644, 'fraction_numerical': 0.009617162936933604, 'mean_word_length': 3.1219512195121952, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6645213', 'n_tokens_mistral': 1938, 'n_tokens_neox': 1855, 'n_words': 357}