<commit_before><?xml version="1.0" encoding="UTF-8"?>
<!--
  - Copyright 2014 Charles University in Prague
  - Copyright 2014 <NAME>
  - 
  - Licensed under the Apache License, Version 2.0 (the "License");
  - you may not use this file except in compliance with the License.
  - You may obtain a copy of the License at
  -
  -     http://www.apache.org/licenses/LICENSE-2.0
  -
  - Unless required by applicable law or agreed to in writing, software
  - distributed under the License is distributed on an "AS IS" BASIS,
  - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - See the License for the specific language governing permissions and
  - limitations under the License.
  -->
<project basedir="." name="Microbenchmarking agent" default="compile">
	<property file="local-settings.ini" />
	
	<property environment="env" />

	<property name="java.src.dir" value="src/java" />
	<property name="agent.src.dir" value="src/c" />
	<property name="java.test.src.dir" value="src/test-java" />

	<property name="build.dir" location="out" />
	<property name="classes.build.dir" location="${build.dir}/classes" />
	<property name="test.classes.build.dir" location="${build.dir}/test-classes" />
	<property name="agent.build.dir" location="${build.dir}/agent/" />
	
	<property name="agent.cc" value="gcc" />

	<condition property="agent.cc.is.gcc">
		<equals arg1="${agent.cc}" arg2="gcc" />
	</condition>
	<condition property="agent.cc.is.msvc">
		<equals arg1="${agent.cc}" arg2="msvc" />
	</condition>
		
	
	<!--
		Determine features (capabilities) of the agent based
		on available libraries or on which platform we are
		operating.
	-->
	<condition property="agent.feature.has.papi">
		<and>
			<os family="unix" />
			<available file="libpapi.so" filepath="/usr/lib" />
		</and>
	</condition>
	
	<!--
		Prepare some compiler/linker settings.
	-->
	<!-- Java include paths -->
	<property name="agent.cc.java.include" location="${env.JAVA_HOME}/include" />
	<condition property="agent.cc.java.os.include" value="${env.JAVA_HOME}/include/linux">
		<os name="Linux" />
	</condition>
	<condition property="agent.cc.java.os.include" value="${env.JAVA_HOME}/include/win32">
		<os family="windows" />
	</condition>
	<!-- PAPI support -->
	<condition property="agent.link.papi" value="-lpapi" else="">
		<isset property="agent.feature.has.papi" />
	</condition>
	<condition property="agent.cc.papi" value="-DHAS_PAPI" else="">
		<isset property="agent.feature.has.papi" />
	</condition>
	
	
	
	
	<target name="print-properties">
		<echoproperties format="text" />
	</target>

	<target name="compile" depends="compile-java,compile-agent">
	</target>

	<target name="compile-java">
		<mkdir dir="${classes.build.dir}" />
		<javac 
				destdir="${classes.build.dir}"
				debug="true"
				includeantruntime="false">
			<src path="${java.src.dir}" />
			<compilerarg value="-Xlint:all"/>
		</javac>
	</target>

	<target name="compile-agent" depends="compile-java,compile-agent-gcc,compile-agent-msvc">
	</target>
	
	<target name="compile-agent-prepare-headers" depends="compile-java">
		<mkdir dir="${agent.build.dir}" />
		<javah
				destdir="${agent.build.dir}"
				classpath="${classes.build.dir}">
			<class name="cz.cuni.mff.d3s.perf.CompilationCounter" />
			<class name="cz.cuni.mff.d3s.perf.Benchmark" />
			<class name="cz.cuni.mff.d3s.perf.OverheadEstimations" />
		</javah>
	</target>
	
	<target name="compile-agent-gcc" depends="compile-agent-prepare-headers" if="agent.cc.is.gcc">
		<apply executable="gcc" dest="${agent.build.dir}" parallel="false" verbose="true">
			<arg value="-c" />
			<arg value="-I${agent.build.dir}" />
			<arg value="-I${agent.cc.java.include}" />
			<arg value="-I${agent.cc.java.os.include}" />
			<arg value="-fPIC" />
			<arg line="${agent.cc.papi}" />
			<arg value="-o"/>
			<targetfile />
			<srcfile />
			<fileset dir="${agent.src.dir}" includes="*.c" />
			<mapper type="glob" from="*.c" to="*.o" />
		</apply>
		<!-- FIXME: do not link when everything is up to date. -->
		<apply executable="gcc" parallel="true" verbose="true">
			<arg value="-shared" />
			<arg value="-fPIC" />
			<arg line="${agent.link.papi}" />
			<arg value="-o" />
			<arg file="${agent.build.dir}/libubench-agent.so" />
			<srcfile />
			<fileset dir="${agent.build.dir}" includes="*.o" />
		</apply>
	</target>
	
	<target name="compile-agent-msvc" depends="compile-agent-prepare-headers" if="agent.cc.is.msvc">
		<apply executable="cl.exe" dest="${agent.build.dir}" parallel="false" verbose="true">
			<arg value="/c" />
			<arg value="/I${agent.build.dir}" />
			<arg value="/I${agent.cc.java.include}" />
			<arg value="/I${agent.cc.java.os.include}" />
			<arg value="/Fo${agent.build.dir}${file.separator}"/>
			<arg value="/TC" />
			<srcfile /><commit_msg>Check for getrusage() and clock_gettime()<commit_after><?xml version="1.0" encoding="UTF-8"?>
<!--
  - Copyright 2014 Charles University in Prague
  - Copyright 2014 <NAME>
  - 
  - Licensed under the Apache License, Version 2.0 (the "License");
  - you may not use this file except in compliance with the License.
  - You may obtain a copy of the License at
  -
  -     http://www.apache.org/licenses/LICENSE-2.0
  -
  - Unless required by applicable law or agreed to in writing, software
  - distributed under the License is distributed on an "AS IS" BASIS,
  - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - See the License for the specific language governing permissions and
  - limitations under the License.
  -->
<project basedir="." name="Microbenchmarking agent" default="compile">
	<property file="local-settings.ini" />
	
	<property environment="env" />

	<property name="java.src.dir" value="src/java" />
	<property name="agent.src.dir" value="src/c" />
	<property name="java.test.src.dir" value="src/test-java" />

	<property name="build.dir" location="out" />
	<property name="classes.build.dir" location="${build.dir}/classes" />
	<property name="test.classes.build.dir" location="${build.dir}/test-classes" />
	<property name="agent.build.dir" location="${build.dir}/agent/" />
	
	<property name="agent.cc" value="gcc" />

	<condition property="agent.cc.is.gcc">
		<equals arg1="${agent.cc}" arg2="gcc" />
	</condition>
	<condition property="agent.cc.is.msvc">
		<equals arg1="${agent.cc}" arg2="msvc" />
	</condition>
		
	
	<!--
		Determine features (capabilities) of the agent based
		on available libraries or on which platform we are
		operating.
	-->
	<condition property="agent.feature.has.papi">
		<and>
			<os family="unix" />
			<available file="libpapi.so" filepath="/usr/lib" />
		</and>
	</condition>
	<condition property="agent.feature.has.getrusage">
		<os name="Linux" />
	</condition>
	<condition property="agent.feature.has.timespec">
		<os name="Linux" />
	</condition>
	
	<!--
		Prepare some compiler/linker settings.
	-->
	<!-- Java include paths -->
	<property name="agent.cc.java.include" location="${env.JAVA_HOME}/include" />
	<condition property="agent.cc.java.os.include" value="${env.JAVA_HOME}/include/linux">
		<os name="Linux" />
	</condition>
	<condition property="agent.cc.java.os.include" value="${env.JAVA_HOME}/include/win32">
		<os family="windows" />
	</condition>
	<!-- PAPI support -->
	<condition property="agent.link.papi" value="-lpapi" else="">
		<isset property="agent.feature.has.papi" />
	</condition>
	<condition property="agent.cc.papi" value="-DHAS_PAPI" else="">
		<isset property="agent.feature.has.papi" />
	</condition>
	<condition property="agent.cc.getrusage" value="-DHAS_GETRUSAGE" else="">
		<isset property="agent.feature.has.getrusage" />
	</condition>
	<condition property="agent.cc.timespec" value="-DHAS_TIMESPEC" else="">
		<isset property="agent.feature.has.timespec" />
	</condition>	
	
	
	
	<target name="print-properties">
		<echoproperties format="text" />
	</target>

	<target name="compile" depends="compile-java,compile-agent">
	</target>

	<target name="compile-java">
		<mkdir dir="${classes.build.dir}" />
		<javac 
				destdir="${classes.build.dir}"
				debug="true"
				includeantruntime="false">
			<src path="${java.src.dir}" />
			<compilerarg value="-Xlint:all"/>
		</javac>
	</target>

	<target name="compile-agent" depends="compile-java,compile-agent-gcc,compile-agent-msvc">
	</target>
	
	<target name="compile-agent-prepare-headers" depends="compile-java">
		<mkdir dir="${agent.build.dir}" />
		<javah
				destdir="${agent.build.dir}"
				classpath="${classes.build.dir}">
			<class name="cz.cuni.mff.d3s.perf.CompilationCounter" />
			<class name="cz.cuni.mff.d3s.perf.Benchmark" />
			<class name="cz.cuni.mff.d3s.perf.OverheadEstimations" />
		</javah>
	</target>
	
	<target name="compile-agent-gcc" depends="compile-agent-prepare-headers" if="agent.cc.is.gcc">
		<apply executable="gcc" dest="${agent.build.dir}" parallel="false" verbose="true">
			<arg value="-c" />
			<arg value="-I${agent.build.dir}" />
			<arg value="-I${agent.cc.java.include}" />
			<arg value="-I${agent.cc.java.os.include}" />
			<arg value="-fPIC" />
			<arg line="${agent.cc.papi}" />
			<arg line="${agent.cc.getrusage}" />
			<arg line="${agent.cc.timespec}" />
			<arg value="-o"/>
			<targetfile />
			<srcfile />
			<fileset dir="${agent.src.dir}" includes="*.c" />
			<mapper type="glob" from="*.c" to="*.o" />
		</apply>
		<!-- FIXME: do not link when everything is up to date. -->
		<apply executable="gcc" parallel="true" verbose="true">
			<arg value="-shared" />
			<arg value="-fPIC" />
			<arg line="${agent.link.papi}" />
			<arg value="-o" />
			<arg file="${agent.build.dir}/libubench-agent.so" />
			<srcfile />
			<fileset dir="${agent.build.dir}" includes="*.o" />
		</apply>
	</target>
	
	<target name="compile-agent-msvc" depends="compile-agent-prepare-headers" if="agent.cc.is.msvc">
		<apply executable="cl.exe" dest="${agent.build.dir}" parallel="false" verbose="true">
			<arg value="/c" />
			<arg value="/I${agent.build.dir}" />
			<arg value="/I${agent.cc.java.include}" />
			<arg value="/I${agent.cc.java.os.include}" />
			<arg value="/Fo${agent.build.dir}${file.separator}"/>
			<arg value="/TC" />
			<srcfile />
{'fraction_non_alphanumeric': 0.20255905511811023, 'fraction_numerical': 0.004724409448818898, 'mean_word_length': 3.87104506232023, 'pattern_counts': {'":': 0, '<': 215, '<?xml version=': 2, '>': 215, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '6553253', 'n_tokens_mistral': 3752, 'n_tokens_neox': 3391, 'n_words': 688}