<commit_before>/*******************************************************************************
 * Copyright (c) 2014-2016, IncQuery Labs Ltd.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME> - initial API and implementation
 *******************************************************************************/

package com.incquerylabs.examples.cps.performance.tests.config.phases

import com.incquerylabs.examples.cps.performance.tests.config.CPSDataToken
import eu.mondo.sam.core.metrics.MemoryMetric
import eu.mondo.sam.core.metrics.TimeMetric
import org.eclipse.core.runtime.Platform
import org.eclipse.viatra.examples.cps.xform.m2t.api.ChangeM2TOutputProvider
import org.eclipse.viatra.examples.cps.xform.serializer.DefaultSerializer
import org.eclipse.viatra.examples.cps.xform.serializer.eclipse.EclipseBasedFileAccessor
import org.eclipse.viatra.examples.cps.xform.serializer.javaio.JavaIOBasedFileAccessor

class M2TDeltaTransformationPhase extends CPSBenchmarkPhase {
	protected extension DefaultSerializer serializer = new DefaultSerializer

	new(String name) {
		super(name, true)
	}

	override execute(CPSDataToken cpsToken, TimeMetric timer, MemoryMetric memory) {

		timer.startMeasure

		val monitor = cpsToken.changeMonitor
		val generator = cpsToken.codeGenerator
		val folder = cpsToken.srcFolder
		val folderString = if(folder != null){
			folder.location.toOSString
		} else {
			cpsToken.folderPath
		}
		val delta = monitor.deltaSinceLastCheckpoint
	
		
		val changeprovider = new ChangeM2TOutputProvider(delta, generator, folderString)
		val fileAccessor = if(Platform.running){
			new EclipseBasedFileAccessor
		} else {
			new JavaIOBasedFileAccessor
		}
		folderString.serialize(changeprovider, fileAccessor)

		timer.stopMeasure
		memory.measure
		return emptySet
	}
}<commit_msg>M2T delta tranformation should create checkpoint<commit_after>/*******************************************************************************
 * Copyright (c) 2014-2016, IncQuery Labs Ltd.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME> - initial API and implementation
 *******************************************************************************/

package com.incquerylabs.examples.cps.performance.tests.config.phases

import com.incquerylabs.examples.cps.performance.tests.config.CPSDataToken
import eu.mondo.sam.core.metrics.MemoryMetric
import eu.mondo.sam.core.metrics.TimeMetric
import org.eclipse.core.runtime.Platform
import org.eclipse.viatra.examples.cps.xform.m2t.api.ChangeM2TOutputProvider
import org.eclipse.viatra.examples.cps.xform.serializer.DefaultSerializer
import org.eclipse.viatra.examples.cps.xform.serializer.eclipse.EclipseBasedFileAccessor
import org.eclipse.viatra.examples.cps.xform.serializer.javaio.JavaIOBasedFileAccessor

class M2TDeltaTransformationPhase extends CPSBenchmarkPhase {
	protected extension DefaultSerializer serializer = new DefaultSerializer

	new(String name) {
		super(name, true)
	}

	override execute(CPSDataToken cpsToken, TimeMetric timer, MemoryMetric memory) {

		timer.startMeasure

		val monitor = cpsToken.changeMonitor
		val generator = cpsToken.codeGenerator
		val folder = cpsToken.srcFolder
		val folderString = if(folder !== null){
			folder.location.toOSString
		} else {
			cpsToken.folderPath
		}
		val delta = monitor.createCheckpoint
		
		val changeprovider = new ChangeM2TOutputProvider(delta, generator, folderString)
		val fileAccessor = if(Platform.running){
			new EclipseBasedFileAccessor
		} else {
			new JavaIOBasedFileAccessor
		}
		folderString.serialize(changeprovider, fileAccessor)

		timer.stopMeasure
		memory.measure
		return emptySet
	}
}
{'fraction_non_alphanumeric': 0.15536992840095465, 'fraction_numerical': 0.007875894988066826, 'mean_word_length': 5.52803738317757, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2022611', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1152, 'n_words': 261}