src/Pure/Build/build_benchmark.scala
author Fabian Huch <huch@in.tum.de>
Wed, 05 Jun 2024 17:41:16 +0200
changeset 80255 1844c169e360
parent 80128 2fe244c4bb01
permissions -rw-r--r--
ensure permissions when starting build task (e.g., due to misconfigured client);
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
79874
1e7b5a258bc5 proper file headers;
wenzelm
parents: 79777
diff changeset
     1
/*  Title:      Pure/Build/build_benchmark.scala
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
     2
    Author:     Fabian Huch, TU Muenchen
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
     3
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
     4
Host platform benchmarks for performance estimation.
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
     5
*/
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
     6
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
     7
package isabelle
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
     8
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
     9
79947
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
    10
import scala.collection.mutable
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
    11
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
    12
79620
3914bca631b9 clarified directories;
wenzelm
parents: 79618
diff changeset
    13
object Build_Benchmark {
79625
96bfb554b216 tuned comments;
wenzelm
parents: 79624
diff changeset
    14
  /* benchmark */
79291
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    15
79948
8fe1ed4b5705 option for benchmark session;
Fabian Huch <huch@in.tum.de>
parents: 79947
diff changeset
    16
  def benchmark_session(options: Options) = options.string("build_benchmark_session")
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    17
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    18
  def benchmark_command(
79948
8fe1ed4b5705 option for benchmark session;
Fabian Huch <huch@in.tum.de>
parents: 79947
diff changeset
    19
    options: Options,
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    20
    host: Build_Cluster.Host,
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    21
    ssh: SSH.System = SSH.Local,
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    22
    isabelle_home: Path = Path.current,
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    23
  ): String = {
79932
748c5f344707 always provide build_database_server option in benchmark command;
Fabian Huch <huch@in.tum.de>
parents: 79899
diff changeset
    24
    val benchmark_options =
79948
8fe1ed4b5705 option for benchmark session;
Fabian Huch <huch@in.tum.de>
parents: 79947
diff changeset
    25
      List(
8fe1ed4b5705 option for benchmark session;
Fabian Huch <huch@in.tum.de>
parents: 79947
diff changeset
    26
        Options.Spec.eq("build_hostname", host.name),
8fe1ed4b5705 option for benchmark session;
Fabian Huch <huch@in.tum.de>
parents: 79947
diff changeset
    27
        Options.Spec("build_database_server"),
8fe1ed4b5705 option for benchmark session;
Fabian Huch <huch@in.tum.de>
parents: 79947
diff changeset
    28
        options.spec("build_benchmark_session"))
79624
8e97d1fcbbc2 clarified signature;
wenzelm
parents: 79621
diff changeset
    29
    ssh.bash_path(Isabelle_Tool.exe(isabelle_home)) + " build_benchmark" +
79932
748c5f344707 always provide build_database_server option in benchmark command;
Fabian Huch <huch@in.tum.de>
parents: 79899
diff changeset
    30
      Options.Spec.bash_strings(benchmark_options ::: host.options, bg = true)
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    31
  }
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    32
79641
wenzelm
parents: 79639
diff changeset
    33
  def benchmark_requirements(options: Options, progress: Progress = new Progress): Unit = {
79948
8fe1ed4b5705 option for benchmark session;
Fabian Huch <huch@in.tum.de>
parents: 79947
diff changeset
    34
    val options1 = options.string.update("build_engine", Build.Engine.Default.name)
8fe1ed4b5705 option for benchmark session;
Fabian Huch <huch@in.tum.de>
parents: 79947
diff changeset
    35
    val selection =
8fe1ed4b5705 option for benchmark session;
Fabian Huch <huch@in.tum.de>
parents: 79947
diff changeset
    36
      Sessions.Selection(requirements = true, sessions = List(benchmark_session(options)))
8fe1ed4b5705 option for benchmark session;
Fabian Huch <huch@in.tum.de>
parents: 79947
diff changeset
    37
    val res = Build.build(options1, selection = selection, progress = progress, build_heap = true)
79291
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    38
    if (!res.ok) error("Failed building requirements")
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    39
  }
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    40
79947
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
    41
  def run_benchmark(options: Options, progress: Progress = new Progress): Unit = {
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    42
    val hostname = options.string("build_hostname")
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    43
    val store = Store(options)
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    44
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    45
    using(store.open_server()) { server =>
79291
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    46
      using_optional(store.maybe_open_database_server(server = server)) { database_server =>
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    47
        val db = store.open_build_database(path = Host.private_data.database, server = server)
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    48
79617
cdb51c7225ad tuned message;
wenzelm
parents: 79602
diff changeset
    49
        progress.echo("Starting benchmark ...")
79948
8fe1ed4b5705 option for benchmark session;
Fabian Huch <huch@in.tum.de>
parents: 79947
diff changeset
    50
        val benchmark_session_name = benchmark_session(options)
8fe1ed4b5705 option for benchmark session;
Fabian Huch <huch@in.tum.de>
parents: 79947
diff changeset
    51
        val selection = Sessions.Selection(sessions = List(benchmark_session_name))
79657
cff4576218fa tuned: afford untyped/unscoped update;
wenzelm
parents: 79644
diff changeset
    52
        val full_sessions = Sessions.load_structure(options + "threads=1")
79291
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    53
79644
389c1bfa7c3e clarified signature: more standard defaults;
wenzelm
parents: 79642
diff changeset
    54
        val build_deps = Sessions.deps(full_sessions.selection(selection)).check_errors
389c1bfa7c3e clarified signature: more standard defaults;
wenzelm
parents: 79642
diff changeset
    55
        val build_context = Build.Context(store, build_deps, jobs = 1)
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    56
79291
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    57
        val sessions = Build_Process.Sessions.empty.init(build_context, database_server, progress)
79948
8fe1ed4b5705 option for benchmark session;
Fabian Huch <huch@in.tum.de>
parents: 79947
diff changeset
    58
        val session = sessions(benchmark_session_name)
79291
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    59
79682
1fa1b32b0379 build local log_db, with store/restore via optional database server;
wenzelm
parents: 79660
diff changeset
    60
        val hierachy = session.ancestors.map(store.output_session(_, store_heap = true))
79698
b676998d7f97 clarified signature;
wenzelm
parents: 79682
diff changeset
    61
        for (db <- database_server) ML_Heap.restore(db, hierachy, cache = store.cache.compress)
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    62
79660
49475f8bb4cc tuned: afford untyped/unscoped update;
wenzelm
parents: 79657
diff changeset
    63
        val local_options = options + "build_database_server=false" + "build_database=false"
79295
123651f3ec5d restore benchmark requirement heaps properly;
Fabian Huch <huch@in.tum.de>
parents: 79291
diff changeset
    64
123651f3ec5d restore benchmark requirement heaps properly;
Fabian Huch <huch@in.tum.de>
parents: 79291
diff changeset
    65
        benchmark_requirements(local_options, progress)
79698
b676998d7f97 clarified signature;
wenzelm
parents: 79682
diff changeset
    66
        for (db <- database_server) ML_Heap.restore(db, hierachy, cache = store.cache.compress)
79295
123651f3ec5d restore benchmark requirement heaps properly;
Fabian Huch <huch@in.tum.de>
parents: 79291
diff changeset
    67
80125
wenzelm
parents: 80124
diff changeset
    68
        def get_shasum(name: String): SHA1.Shasum =
wenzelm
parents: 80124
diff changeset
    69
          store.check_output(database_server, name,
wenzelm
parents: 80124
diff changeset
    70
            sources_shasum = sessions(name).sources_shasum,
80128
2fe244c4bb01 clarified signature;
wenzelm
parents: 80125
diff changeset
    71
            input_shasum = ML_Process.make_shasum(sessions(name).ancestors.map(get_shasum)),
2fe244c4bb01 clarified signature;
wenzelm
parents: 80125
diff changeset
    72
            build_thorough = build_context.sessions_structure(name).build_thorough)._2
79291
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    73
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    74
        val deps = Sessions.deps(full_sessions.selection(selection)).check_errors
79948
8fe1ed4b5705 option for benchmark session;
Fabian Huch <huch@in.tum.de>
parents: 79947
diff changeset
    75
        val background = deps.background(benchmark_session_name)
8fe1ed4b5705 option for benchmark session;
Fabian Huch <huch@in.tum.de>
parents: 79947
diff changeset
    76
        val input_shasum = get_shasum(benchmark_session_name)
79291
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    77
        val node_info = Host.Node_Info(hostname, None, Nil)
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    78
79295
123651f3ec5d restore benchmark requirement heaps properly;
Fabian Huch <huch@in.tum.de>
parents: 79291
diff changeset
    79
        val local_build_context = build_context.copy(store = Store(local_options))
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    80
79887
17220dc05991 revert most parts of 0e79fa88cab6: somewhat ambitious attempt to move towards "editing" builds via added/canceled workers;
wenzelm
parents: 79874
diff changeset
    81
        val result =
79777
db9c6be8e236 prefer dynamic objects, following a5fda30edae2;
wenzelm
parents: 79698
diff changeset
    82
          Build_Job.start_session(local_build_context, session, progress, new Logger, server,
79887
17220dc05991 revert most parts of 0e79fa88cab6: somewhat ambitious attempt to move towards "editing" builds via added/canceled workers;
wenzelm
parents: 79874
diff changeset
    83
            background, session.sources_shasum, input_shasum, node_info, false).join
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    84
79291
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    85
        val timing =
79887
17220dc05991 revert most parts of 0e79fa88cab6: somewhat ambitious attempt to move towards "editing" builds via added/canceled workers;
wenzelm
parents: 79874
diff changeset
    86
          if (result.process_result.ok) result.process_result.timing
17220dc05991 revert most parts of 0e79fa88cab6: somewhat ambitious attempt to move towards "editing" builds via added/canceled workers;
wenzelm
parents: 79874
diff changeset
    87
          else error("Failed to build benchmark session")
79291
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    88
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    89
        val score = Time.seconds(1000).ms.toDouble / (1 + timing.elapsed.ms)
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    90
        progress.echo(
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    91
          "Finished benchmark in " + timing.message + ". Score: " + String.format("%.2f", score))
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    92
79602
9ba800f12785 clarified signature;
wenzelm
parents: 79295
diff changeset
    93
        Host.write_info(db, Host.Info.init(hostname = hostname, score = Some(score)))
79291
e9a788a75775 use single-threaded session build as benchmark (using ZF-Constructible);
Fabian Huch <huch@in.tum.de>
parents: 78916
diff changeset
    94
      }
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    95
    }
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    96
  }
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
    97
79947
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
    98
  def benchmark(
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
    99
    options: Options,
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   100
    build_hosts: List[Build_Cluster.Host] = Nil,
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   101
    progress: Progress = new Progress
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   102
  ): Unit =
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   103
    if (build_hosts.isEmpty) run_benchmark(options, progress)
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   104
    else {
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   105
      val engine = Build.Engine.Default
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   106
      val store = engine.build_store(options, build_cluster = true)
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   107
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   108
      benchmark_requirements(store.options, progress)
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   109
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   110
      val deps0 = Sessions.deps(Sessions.load_structure(options))
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   111
      val build_context = Build.Context(store, deps0, build_hosts = build_hosts)
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   112
79949
bc39a468ace6 raise error if benchmarking fails;
Fabian Huch <huch@in.tum.de>
parents: 79948
diff changeset
   113
      val build_cluster = Build_Cluster.make(build_context, progress).open().init().benchmark()
bc39a468ace6 raise error if benchmarking fails;
Fabian Huch <huch@in.tum.de>
parents: 79948
diff changeset
   114
      if (!build_cluster.ok) error("Benchmarking failed")
bc39a468ace6 raise error if benchmarking fails;
Fabian Huch <huch@in.tum.de>
parents: 79948
diff changeset
   115
      build_cluster.stop()
79947
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   116
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   117
      using(store.open_server()) { server =>
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   118
        val db = store.open_build_database(path = Host.private_data.database, server = server)
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   119
        for (build_host <- build_hosts) {
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   120
          val score =
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   121
            (for {
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   122
              info <- Host.read_info(db, build_host.name)
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   123
              score <- info.benchmark_score
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   124
            } yield score).getOrElse(error("No score for host " + quote(build_host.name)))
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   125
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   126
          progress.echo(build_host.name + ": " + score)
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   127
        }
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   128
      }
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   129
    }
79625
96bfb554b216 tuned comments;
wenzelm
parents: 79624
diff changeset
   130
96bfb554b216 tuned comments;
wenzelm
parents: 79624
diff changeset
   131
  /* Isabelle tool wrapper */
96bfb554b216 tuned comments;
wenzelm
parents: 79624
diff changeset
   132
79620
3914bca631b9 clarified directories;
wenzelm
parents: 79618
diff changeset
   133
  val isabelle_tool = Isabelle_Tool("build_benchmark", "run benchmark for build process",
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   134
    Scala_Project.here,
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   135
    { args =>
79947
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   136
      val build_hosts = new mutable.ListBuffer[Build_Cluster.Host]
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   137
      var options = Options.init()
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   138
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   139
      val getopts = Getopts("""
79620
3914bca631b9 clarified directories;
wenzelm
parents: 79618
diff changeset
   140
Usage: isabelle build_benchmark [OPTIONS]
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   141
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   142
  Options are:
79947
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   143
    -H HOSTS     additional cluster host specifications of the form
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   144
                 NAMES:PARAMETERS (separated by commas)
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   145
    -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   146
79620
3914bca631b9 clarified directories;
wenzelm
parents: 79618
diff changeset
   147
  Run benchmark for build process.
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   148
""",
79947
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   149
        "H:" -> (arg => build_hosts ++= Build_Cluster.Host.parse(Registry.global, arg)),
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   150
        "o:" -> (arg => options = options + arg))
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   151
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   152
      val more_args = getopts(args)
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   153
      if (more_args.nonEmpty) getopts.usage()
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   154
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   155
      val progress = new Console_Progress()
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   156
79947
5eb90c1ce653 add hosts option to run benchmark on the cluster from the command-line;
Fabian Huch <huch@in.tum.de>
parents: 79932
diff changeset
   157
      benchmark(options, build_hosts = build_hosts.toList, progress = progress)
78840
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   158
    })
4b528ca25573 added initial version of benchmark module, e.g., to compare performance of different hosts;
Fabian Huch <huch@in.tum.de>
parents:
diff changeset
   159
}