<commit_before>package ru.agentlab.maia.memory.context.test.perf

import com.javamex.classmexer.MemoryUtil
import java.io.PrintWriter
import java.util.UUID
import org.junit.Test
import ru.agentlab.maia.memory.IMaiaContext
import ru.agentlab.maia.memory.doubles.DummyService

abstract class AbstractContextSetMemoryTests {

	@Test
	def void test() {
		val totalSize = 1_000
		val keys = newArrayOfSize(totalSize)
		val services = newArrayOfSize(totalSize)
		val results = newArrayOfSize(totalSize)

		for (i : 0 ..< totalSize) {
			val key = UUID.randomUUID.toString
			keys.set(i, key)
			val service = new DummyService
			services.set(i, service)
		}
		for (i : 0 ..< totalSize) {
			context.set(keys.get(i), services.get(i))
			results.set(i, MemoryUtil.deepMemoryUsageOf(context))
		}
//		}
		val writer = new PrintWriter('''target/results/«context.class.simpleName»_memory.csv''', "UTF-8")
		for (i : 0 ..< totalSize) {
			writer.println(results.get(i))
		}
		writer.close
	}

	def IMaiaContext getContext()

}<commit_msg>* optimize memory test<commit_after>package ru.agentlab.maia.memory.context.test.perf

import com.javamex.classmexer.MemoryUtil
import java.io.PrintWriter
import java.util.UUID
import org.junit.Test
import ru.agentlab.maia.memory.IMaiaContext
import ru.agentlab.maia.memory.doubles.DummyService

abstract class AbstractContextSetMemoryTests {

	@Test
	def void test() {
		val totalSize = 1_000
		val results = newArrayOfSize(totalSize)

		for (i : 0 ..< totalSize) {
			context.set(UUID.randomUUID.toString, new DummyService)
			results.set(i, MemoryUtil.deepMemoryUsageOf(context))
		}
		
		val writer = new PrintWriter('''target/results/«context.class.simpleName»_memory.csv''', "UTF-8")
		for (i : 0 ..< totalSize) {
			writer.println(results.get(i))
		}
		writer.close
	}

	def IMaiaContext getContext()

}
{'fraction_non_alphanumeric': 0.12309368191721133, 'fraction_numerical': 0.008169934640522876, 'mean_word_length': 4.278735632183908, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, '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': '7596161', 'n_tokens_mistral': 701, 'n_tokens_neox': 641, 'n_words': 131}