<commit_before>package tutor

import java.io.File

import tutor.utils.FileUtil.Path
import tutor.utils.WriteSupport

object MainApp extends App with ReportFormatter with WriteSupport {
  if (args.length < 1) {
    println("usage: CodeAnalyzer FilePath [-oOutputfile]")
  } else {
    val path: Path = args(0)
    val file = new File(path)
    val analyzer = new CodebaseAnalyzer with DirectoryScanner with SourceCodeAnalyzer
    val rs = if (file.isFile) {
      format(analyzer.processFile(file.getAbsolutePath))
    } else {
      analyzer.analyze(path, KnowFileTypes.knownFileTypes).map(format).getOrElse("not result found")
    }
    if (args.length > 1) {
      val output = args(1).drop(2)
      withWriter(output) {
        _.write(rs)
      }
      println(s"report saved into $output")
    } else {
      println(rs)
    }
  }

}<commit_msg>add output to show how many times elapsed for analyze<commit_after>package tutor

import java.io.File
import java.text.SimpleDateFormat
import java.util.Date

import com.typesafe.scalalogging.slf4j.StrictLogging
import tutor.utils.FileUtil.Path
import tutor.utils.WriteSupport

object MainApp extends App with ReportFormatter with WriteSupport with StrictLogging {
  if (args.length < 1) {
    println("usage: CodeAnalyzer FilePath [-oOutputfile]")
  } else {
    val path: Path = args(0)
    val file = new File(path)
    val analyzer = new CodebaseAnalyzer with DirectoryScanner with SourceCodeAnalyzer
    val rs = if (file.isFile) {
      format(analyzer.processFile(file.getAbsolutePath))
    } else {
      logger.info("start analyzing...")
      val beginTime = new Date
      val anayRs = analyzer.analyze(path, KnowFileTypes.knownFileTypes).map(format).getOrElse("not result found")
      logger.info("analyze complete")
      val endTime = new Date
      val elapsed = new Date(endTime.getTime - beginTime.getTime)
      val sdf = new SimpleDateFormat("hh:mm:ss.SSS")
      logger.info(s"total elapsed ${sdf.format(elapsed)}")
      anayRs
    }
    if (args.length > 1) {
      val output = args(1).drop(2)
      withWriter(output) {
        _.write(rs)
      }
      println(s"report saved into $output")
    } else {
      println(rs)
    }
  }

}
{'fraction_non_alphanumeric': 0.10452488687782806, 'fraction_numerical': 0.004977375565610859, 'mean_word_length': 3.1875, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2957852', 'n_tokens_mistral': 717, 'n_tokens_neox': 685, 'n_words': 172}