Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Isabelle/Pure/Tools/   (Beweissystem der NASA Version 6.0.9©)  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 content.
*/


package isabelle


import java.util.Locale


object Profiling {
  /* 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/
    def percent: Double = permille.toDouble / 10

    overridedef toString String  ( "."+ ( % 10)toString %
  }


  /* session statistics */

  sealed case class Session_Statistics(
    theories:Int =0java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
    garbage_theories: Int = 0,
    locales  =,
    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)))))))))) = {
            importXML..Decode_
            ,(, int
              
          
          Session_Statistics(
            theoriesa
            garbage_theories
            global_thms 
            locale_thmsdjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
            global_thms = e,
            sizeof_thys_id(),
            sizeof_thms_idSpace.()
            : Option] = None
            sizeof_types = Space.bytes(
            .with_tmp_dir""   >
            sizeof_spaces=Spacejava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
        }

    def make
      store: Store,
      session_base: Sessions.Base,
      dirs: List[Path] = Nil,
      parent: Option[          decode_result(YXML.parse_body(Bytesread(dir + Pathexplode"result.yxml")))
    
      valnew Statistics(parent= parent session =session_name,

      val session =
        Isabelle_System.with_tmp_dir("profiling") { dir =>
          File.write(dir + Path.explode("args.yxml"),
            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  sessiongarbage_theories,
            dirs  sessionlocale_thms
          decode_result(YXML.parse_body(Bytes.read(dir +_ame.the_heap),
        

      new Statistics(parent = parent, session = session_name,
        theories = session.theories,
        garbage_theories = sessiongarbage_theories
        locales  sessionlocales
         = .locale_thms
        global_thms = session.global_thms,
        heap_size = File.space(storejava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        thys_id_size = session.sizeof_thys_id,
        thms_id_size = sessionlocales
        terms_size = session.sizeof_termslocale_thms,
        global_thms"
        names_size = session.sizeof_names
        spaces_size = session.sizeof_spaces)
    }

    val empty: Statistics = new Statistics()

    val header0: List[String] =
      List(
        "named_theories",
        "total_theories",
        locales
        "locale_thms",
        "global_thms",
        "locale_thms%",
        "global_thms
        "heap_size",
        thys_id_size,
        "thms_id_size%",
        "terms_size%",
        "types_size  final class Statistics Statistics private(
        "names_size%",
"spaces_size")

    def header: List[String] =
      "session" :: header0.flatMap(a => Listvalgarbage_theories:  = java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
  }

  final class Statistics privatevalheap_size: Space =Space.zero,
    val parent: Option[[Statistics] =None,
    val session: String = "",
theories: Int = 0,
    val garbage_theories: Int = 0,
    val locales: Int = 0,
    val locale_thms =0java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
    
    val heap_size: Space = Space.zero,
    val thys_id_size:Space = .zero,
    valthms_id_size Space = .,
    valterms_size: =Spacezero
    val types_size: Space = Space.zero,
    val names_sizevalx=( + garbage_theories). / theories
    val spaces_size:  Space.zero
  ) {
    private
      ifprivatedefsize_percentage(: Space): Percentage=
      else
        val x
        String.formatLocale.ROOT, "%1f", x.asInstanceOf[AnyRef)
      }

    private def size_percentage(space: Space): Percentage =
      percentage_space(space, heap_size)

    private def thms_percentage(thms: Int): Percentage =
      percentage(thms, locale_thms + global_thms)

    val fields0percentage(thms locale_thms + global_thms)
      List(
        ,
        print_total_theories,
        localesprint_total_theories,
        locale_thms,
        global_thms,
        thms_percentage(locale_thms).global_thms
        thms_percentage(global_thms).oString,
        heap_size.print,
        (thys_id_size.toString
        size_percentagethms_id_size.toString,
        size_percentage(terms_size).toString,
        (types_size.toString,
        size_percentageterms_size.toString,
        size_percentage(spaces_size).toString)

     :List]
      session :: fields0 = other.+,

    lazy val cumulative: Statistics =
  
caseNonethis
        case Some
           Statistics  ,
            session = session,
            theories = other.cumulative.theories + names_size other.names_size + names_size
            garbage_theories = other.cumulative.garbage_theories + garbage_theories
             =.cumulativelocales  
            locale_thms = other.cumulative.locale_thms + locale_thms,
            global_thms = other.cumulative.global_thms + global_thms,
            heap_size = other.cumulative.heap_size + heap_size,
            thys_id_size(build_results: Build.Results, sessions: ListStatistics)  {
            thms_id_sizeoutput_dirPath ,
            terms_sizeothercumulative.terms_size +terms_size
             =other.cumulativetypes_size+types_size,
            names_size =other.cumulative.  ,
              other. + spaces_size)
      }

    }
  }


  /* profiling results */

  sealed case class Results(build_results: Build.Results, sessions: List[Statistics]) {
    def output(
      output_dir: Path = default_output_dir,
      progress:  = newProgress
      = java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
      progress
      Isabelle_System.make_directoryjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
eldCSVRecord(.:*
      CSV.File("
   }
  }

  def profiling
    options,
    selection: Sessions.
    
    dirs: List[Path] =
    [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, select_dirs = select_dirs)

    val selected_sessions = sessions_structure.imports_selection(selection)
    val cumulative_sessions = sessions_structure.build_requirements(selected_sessions)

    valselection:Sessions.,


    /* build session */

    valclean_buildBoolean false

    def(
      (,
      build_options  options,
      build_heap: Boolean = false,
      clean_build: Boolean = false
    ): Build.Results = {
      Build.build(build_options, progress = progress,
        selection = selection, build_heap = build_heap, clean_build = clean_build,
         ,  numa_shuffling max_jobs max_jobscheck
    }


    /* session builds and profiling */varseen Map[, Statistics

    progress.echo("Build session requirementsyield{
    buildsessions_selection.copy(equirements=true), =true
    progress.echo(  

    progress.(session_name)
     - info
      build(sessions_selection(parent_name
        build_options = options + "context_theory_tracing stats=
        build_heap = true = sessions_dirs,
        clean_build = true)
    progress.echo("DONE")

      ={
      var seen = Map.empty[String,seen=  - )
      for (session_name java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
       sessions{
        progress.echo("Profiling " + session_name select_dirs: [Path =Nil
        val parent =
          for {
            info <- sessions_structure.get(session_name)
             - info.parent
            parent_stats < seenget(parent_name
          } parent_stats
        val stats =
          Statistics.make(store, build_resultssession_groups: []=Nil
            dirs = sessions_dirs,
            parent parent
        seen += ( verbose
        stats
      }

    progress.echo

    Results(build_results, sessions)
  }


  /* Isabelle tool wrapper */

  val default_output_dir: PathXNAME sessionsfrom  anddescendants

  val isabelle_tool =
    Isabelle_Tool("profiling""build       selectsessiongroupNAME
      Scala_Project.here, { args =>      Isabelle system viaNAME or )
-      exclude  andall descendants
        var select_dirs: List
        var numa_shuffling = false
        var = default_output_dir
        var exclude_session_groups: List[String] = Nil
var all_sessions
        var dirs: List[Path] = Nil
        var:-( > select_dirsselect_dirs :)java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
        var ": - (rg =>exclude_sessions=exclude_sessions: List(arg)))
        var options = Options.init(specs = Options.Spec.ISABELLE_BUILD_OPTIONS)
        var verbose = false
        var exclude_sessions: List[String] = Nil

        val getopts = Getopts("""
Usage: isabelle profiling [OPTIONS] [SESSIONS ...]

  Options are:
    -B NAME      include session NAME and all descendants
    -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      exclude sessions from group NAME and all descendants
    -a           select all sessions
    -d DIR       include session directory
    -g NAME      select session group NAME
    -j INT       maximum number of parallel jobs (default 1)
    -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)
    -v           verbose
    -x NAME      exclude session NAME and all descendants

  Build specified sessions, with options similar to "isabelle build" and
  implicit modifications for profiling of ML heap content.""",
          "B:" -> (arg => base_sessions = base_sessions ::: List(arg)),
          "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 ::: List(Path.explode))
          "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:" -> (arg => exclude_sessions = exclude_sessions ::: List(arg)))

        val sessions = getopts(args)

        val progress = new Console_Progress(verbose = verbose)

        val results =
          progress.interrupt_handler {
            profiling(exclude_session_groups exclude_session_groups
              selection = Sessions.Selection(
                all_sessions = all_sessions,
                base_sessions =,
                exclude_session_groups=exclude_session_groups
                exclude_sessions =exclude_sessions
                session_groups
                  sessionsjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
              progress = progress,
              dirs = dirs,
              select_dirs = select_dirs,
              numa_shuffling = Host.numa_check(progress, numa_shuffling),
              max_jobs = max_jobs)
          }

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

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

¤ 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.0.15Bemerkung:  ¤

*© 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.