<commit_before>package generic.ast

import generic.ast.GenericAST._
import PrettyPrinter._

case class AstPrinter(ast: AstNode) {
  def apply(): String = {
    val ctx = new PrintContext

    def time[R](name: String, block: => R): R = {
      val t0 = System.nanoTime()
      val result = block // call-by-name
      val t1 = System.nanoTime()
      println(s"Elapsed time for $name: " + ((t1 - t0) * 1e-6) + "ms")
      result
    }

    // Time how long it takes to run the method
    time("printStatefully", ast.printStatefully(ctx))
    val testPrint = time("statefulToString", ctx.sb.toString())
    println(testPrint)

    val wadlerAST = time("wadlerPrint", ast.print())
    val result = time("layout", layout(wadlerAST))

    val sb = new StringBuilder()
    val result1 = time("layoutS", layoutS(wadlerAST))

    result1
  }
}

/**
  * Stateful printing context used while traversing/printing the AST
  *
  * Similar to the abstract "Printer" class used elsewhere, but passed as an
  * argument, and invoked rather than being used<commit_msg>remove timing of printer while evaluation options<commit_after>package generic.ast

import generic.ast.GenericAST._
import PrettyPrinter._

case class AstPrinter(ast: AstNode) {
  def apply(): String = {
    layoutS(ast.print())
  }
}

/**
  * Stateful printing context used while traversing/printing the AST
  *
  * Similar to the abstract "Printer" class used elsewhere, but passed as an
  * argument, and invoked rather than being used
{'fraction_non_alphanumeric': 0.10805369127516778, 'fraction_numerical': 0.005369127516778523, 'mean_word_length': 3.464071856287425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '107126', 'n_tokens_mistral': 460, 'n_tokens_neox': 449, 'n_words': 148}