<commit_before><commit_msg>- added script to measure start-up time of LanguageTool   in all languages on a given input sentence (empty sentence   by default).  It can be useful to check for regression in   speed and to compare speed of LanguageTool in different   languages. See comments in script for a description   of how to run it.  It has already proven to be useful   in 2 occasions:   * it helped to identify that SRX was slow (improved     later in r6741 thanks to Jarek Lipski).   * it identified that Hunspell initialization was     slow even when turning off Hunspell rule with     -d HUNSPELL_RULE (fixed in svn r7247 by <NAME>     with lazy intialization).<commit_after>#!/bin/sh
#
# This script measures how long it takes to start up
# LanguageTool with an empty input for each language.
# 3 samples are measured to avoid outliers.
# It also prints the number of XML rules for each language.
# 
# Example:
#
# $ cd languagetool/src/scripts
# $ ./startup-time-lt.sh
# 
# or to measure timing with a sentence "foo bar":
#
# $ ./startup-time-lt.sh "foo bar"
#
# Author: <NAME> <<EMAIL>>

# An optional input sentence for measuring startup time.
# (empty sentence by default)
sentence="$1"

echo 'lang | #rules | startup time in sec (3 samples)'
echo '-----+--------+--------------------------------'

for l in ast be br ca cs da de nl el en eo es fr gl \
         is it km lt ml pl ro ru sk sl sv tl uk zh
do
  # count the number of rules.
  rule_count=$(grep -c '</rule>' ../../dist/rules/$l/grammar.xml)

  # measure startup time of LanguageTool with the
  # give sentence (empty by default).  3 samples
  # are measured to avoid outliers.
  startup_time=""
  for i in 1 2 3
  do
    startup_time="$startup_time $(echo $sentence | \
      time -p \
      java -jar ../../dist/LanguageTool.jar \
           -c utf-8 -l $l - 2>&1 | \
      awk '/^real/ {print $2}')"
  done
  printf "%4s | %6s | $startup_time\n" $l $rule_count
done
{'fraction_non_alphanumeric': 0.1152856407617087, 'fraction_numerical': 0.011322696860524962, 'mean_word_length': 2.702857142857143, 'pattern_counts': {'":': 1, '<': 8, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '6196546', 'n_tokens_mistral': 600, 'n_tokens_neox': 580, 'n_words': 274}