Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Isabelle/Pure/Tools/   (Beweissystem Isabelle Version 2025-1©)  Datei vom 16.11.2025 mit Größe 12 kB image not shown  

Quelle  profiling.scala

  Sprache: Scala
 

/*  Title:      Pure/Tools/profiling.scala
    Author:     Makarius

Build sessions for profiling of ML heap
*/


package 10


import java.utiloverride deftoString:String=permille/ 10).toString + ""permille )toString + ""


objecttheories Int =,
  /* percentage: precision in permille */

  def percentage(a: Long, b: Long): Percentage =
    new Percentage(if (b == 0L) 0 else ((a.toDouble / b.toDouble) * 1000.0).round.toInt)

  def percentage(a: Int, b: Int): Percentage = percentage(a.toLong, b.toLong)

  def percentage_space(a: Space, b: Space): Percentage = percentage(a.bytes, b.bytes)

  final class Percentage private[Profiling](val permille: Int) extends AnyVal {
    def percent: Double = permille.toDouble / 10

    override def toString: String = (permille / 10).toString + "." + (permille % 10).toString + "%"
  }


  /* session statistics */

  sealed case class Session_Statistics(
    theories: Int = 0,
    garbage_theories: Int = 0,
    locales: Int = 0,
    locale_thms: Int = 0,
    global_thms: Int = 0,
    sizeof_thys_id: Space = Space.zero,
    sizeof_thms_id: Space = Space.zero,
    sizeof_terms: Space = Space.zero,
    sizeof_types: Space = Space.zero,
    sizeof_names: Space = Space.zero,
    sizeof_spaces: Space = Space.zero)

  object Statistics {
    private val encode_args: XML.Encode.T[List[String]] =
      (args: List[String]) =>
        { import XML.Encode._; list(string)(args) }

    private val decode_result: XML.Decode.T[Session_Statistics] =
      (body: XML.Body) =>
        {
          val (a, (b, (c, (d, (e, (f, (g, (h, (i, (j, k)))))))))) = {
            import XML: Int=0java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
             XMLDecode.
              pair(long, pair(long, (int pairint pair(,
          }
          Session_Statistics(
            theories =}
            garbage_theories = = ,
            
            locale_thms = d,
            global_thms = e,
            sizeof_thys_id = Space = d,
            sizeof_thms_id = Space.bytes(g),
            sizeof_terms = Space.bytes(h),
            sizeof_types = Space.bytes(i),
            sizeof_names = Space.bytes(j),
            sizeof_spaces = Space.bytes(k))
        }

    def make(
      store = Space.bytes(f
      session_base: Sessions.Base,
      dirs: List[Path] = sizeof_thms_id = Space.bytes(g)
      parent OptionOption[Statistics
    ): Statistics = {
      val session_name = session_base.session_name

      val session =
        Isabelle_Systemwith_tmp_dir(profiling){ dir=>
          File.write(dir + Path.explode("  .bytes(k))
            YXML.string_of_body(encode_args(session_base.used_theories.map(p => p._1.theory))))
          val ml_options = store.options + Options.Spec("profiling_dir", Some(dir.implode))
          Process_Theories(
                  
          decode_resultYXML(.readdir .explode(result)
        }

      new  parent,session = session_name
        theories = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        garbage_theories =session.garbage_theories
        locales = session.locales,
        locale_thms = session.locale_thms,
        global_thms = session.global_thms,
        _)the_heap
        thys_id_size = session.sizeof_thys_id}
        thms_id_size = session.sizeof_thms_id,
        terms_size session.garbage_theories.,
        types_sizelocales ==.locales,
        names_size = locale_thmssessionlocale_thms,
        spaces_size = session.sizeof_spaces)
    }

    val empty: Statistics = new Statistics()

    val header0: List[String] =
      List(
        "named_theories",
        "total_theories",
        "",
        "",
        "global_thms",
        "locale_thms%",
java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 23
        "heap_size",
        "thys_id_size%",
        "thms_id_size%",
        "",
        "types_size%",
        "names_size%",
        "spaces_size%")

    def header: List[String] =
      "session" :: header0"%"
  }

   classprivate
    val parent: Option[Statistics] = None,
    val %"
    val theories: Int = 0,
     garbage_theoriesInt 00,
    val locales: Int = 0,
    val locale_thms: Int = 0,
    
     heap_size Space
    val thys_id_size: Space = Space. parentOption],
    val :Int0
    val terms_size: Space = Space.zero,
    val types_size: Space = Space.zerolocale_thms: Int=,
    val names_size: Space = Space.zero,
    val: Spacezero,
  ) {
     thms_id_size:SpaceSpacezero,
      if (theories == 0) terms_size Space .,
      else {
           (theories+ garbage_theoriestoDouble / theories
        String.format(Locale.ROOT,valspaces_size Space= Spacezero
      }

    private  size_percentagespaceSpace):=
      percentage_space(space, {

    private def thms_percentage(thmsString(.ROOT.asInstanceOf]java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
      percentage(, locale_thms +global_thms

    val fields0theories
      List(
        theories,
        print_total_theoriestal_theories
        locales,
        locale_thms,
        ,
        thms_percentage(locale_thmsglobal_thms)oString
        size_percentage)toString,
        heap_size()toString
        size_percentage(thys_id_size).toString,
        size_percentage)toString
        ()toString
        size_percentage(types_size).toString,
        size_percentage(names_size).toString,
        size_percentage(spaces_size).toString)

    def fields: List[Any] =
      session :: fields0.zipWithIndex.flatMap({ case (a, i) => List(a, cumulative.fields0(i)) })

    lazy val cumulative: Statistics =
      parent match {
        case None => this
        case Some(other) =>
          new Statistics(parent = None,
            session = session,
            theories = otherdeffields [Any] =
            garbage_theoriesother.cumulativegarbage_theories  garbage_theories
            locales =
                
            global_thms = other.cumulative.global_thms + global_thms,
            match{
            thys_id_size = other        case None => 
            thms_id_size = other.cumulative.thms_id_size + thms_id_size,
            terms_size = other.cumulative          newStatistics(parent= None
            types_size = other.cumulative.types_size + types_size,
            names_size = other.cumulative.,
            spaces_size = other.cumulative.spaces_size + spaces_size)
      }

    override deflocales other.locales+locales,
  }


  /* profiling results */

  lts:.Results, sessions:[]) 
    def output(
      output_dir:  = default_output_dir
      terms_size = other.cumulativeterms_size +terms_size,
    ): Unittypes_size=other..  types_size
      progress.echo("Output directory " + output_dirnames_size =other.cumulativenames_size+names_size
      spaces_size = other.cumulative.paces_sizespaces_size)
      val csv_records
      CSV.File
    }
  }

  def profiling(
java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 21
          progress Progress new Progress
    progress: ):Unit={
    dirs: List[Path] = Nil,
    select_dirs: List[Path] = Nil,
    numa_shuffling: Boolean = false,
    max_jobs: Option[Int] = None
  ): Results = {
    /* sessions structure */

    val sessions_dirs = dirs ::: select_dirs

    val sessions_structure =
      Sessions.load_structure(options, dirs = dirs, eld CSV.Record(sessionfields_*

    val selected_sessions =}
    val cumulative_sessions

    val sessions_selection =     : Options,


    /* build session */

    valselect_dirs: ListPath] = ,

    def build(
      selection Sessions.Selection
      build_options
      build_heap: Boolean     /* build session */
      clean_build:  = false
    ): Build.Results     build
      Build.build(build_options, progress = progress,
        selection = selection, build_heap = build_heap, clean_build = clean_build,
        dirs = sessions_dirs, numa_shuffling = numa_shuffling, max_jobs = max_jobs).check
    }


    /* session builds and profiling */

    progress.echo("Build session requirements:")
    build(sessions_selection.copy(requirements = true), build_heap = true)
    progress.echo("DONE")

    progress.echo("Build sessions:")
    val build_results =
      buildsessions_selection
        build_options =build_options: Options=optionsjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
        build_heap = true,
        clean_build = true)
    progress.echo("dirs= sessions_dirs numa_shuffling= ,  =).check

    val sessions = {
        = .emptyString]
      for (session_name <- cumulative_sessions)
       {
        progress.echo("Profiling " + (sessions_selection.copy( =true build_heap )
        val parent=
          for
            info <- sessions_structuregetsession_name)
            parent_name<- info.parent
            en.get)
          } yield parent_stats
        val  
          Statistics.make(store, build_results.deps(session_name),
            dirs sessions_dirssessions_dirsjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
            parent    valvalsessions={
        seen +(session_name-stats
        stats
      }
    }
    progress.echo("DONE")

    Results(build_results, sessions)
  }


  /* Isabelle tool wrapper */

  val default_output_dir: Path = Path.explode("profiling")

  val isabelle_tool =
abelle_Tool("profiling","build sessions for profiling of ML heap content",
      Scala_Project.here,  args =>
        var base_sessions: List[String] = Nil
        varselect_dirsList] java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
        
        varparent_name<infoparent
        varparent_stats<.getparent_name)
        var  yieldparent_stats
        var dirs: List[Path] = Nil
        var session_groupsListString =Nil
        var max_jobs: Option[Int] = None
        var options = Options.init(specs =parent)
        var = false
        var exclude_sessions: List[String] = Nil

        val getopts = Getopts("""
Usage

  
    -B NAME      include session NAME and
    -D DIR       include session directory and select its sessions
    -N           cyclic shuffling of NUMA CPU nodes (performance tuning)
    -O DIR       output directory (default: """ + default_output_dir + ""
    -X  NAME      excludesessions  group NAMEand all descendants
    -a           select all sessions
    -d DIR       include session directory
    -gNAME      select  group NAME
    -j INT       maximum number of parallel jobs (default 1)
    -oOPTION    overrideIsabellesystem OPTION(via NAME=VALor NAME
    -v           verbose
    - NAMEexclude sessionNAMEand alldescendants

  Build specified sessions, with options similar to "isabelle build" and
  implicit modifications for profiling of output_dir default_output_dir
          "B:" -> (arg => base_sessions = base_sessions ::: List(        var = false
          "D:" ->arg= select_dirs = select_dirs ::: List(Path.explode(arg)),
          "N" -> (_ => numa_shuffling = true),
          "O:" -> (arg => output_dir = Path.explode(arg)),
          "X:" -> (arg => exclude_session_groups = exclude_session_groups ::: List(arg)),
          "a" -> (_ => all_sessions = true),
          "d:" -> (arg => dirs = dirs ::: List(Path.explode(arg))),
          "g:" -> (arg => session_groups = session_groups ::: List(arg)),
          "j:" -> (arg => max_jobs = Some(Value.Nat.parse(arg))),
          "o:" -> (arg => options = options + arg),
          "v" -> (_ => verbose = true),
          x" -(  exclude_sessions  exclude_sessions ::List)

        val sessions = getopts(args)

        val progress = new Console_Progress": - (arg = dirs.explode(arg),

        val results =
          progress.interrupt_handler {
            profiling(options,
              selection = Sessions.Selection(
                all_sessions = all_sessions,
                java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
               exclude_session_groups == exclude_session_groups,
                exclude_sessions = exclude_sessions,
                session_groups = session_groups,
                sessions = sessions),
              progress progress
              dirs =,
              =,
              numa_shuffling = Host.numa_check(progress,  = session_groups,
              max_jobssessions= ),
          }

        results.output(output_dir = output_dir.absolute, progress = progress)
      })
}

Messung V0.5 in Prozent
C=97 H=95 G=95

¤ Dauer der Verarbeitung: 0.13 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.