Commit 06a7e2c3 authored by Erwan Bousse's avatar Erwan Bousse
Browse files

Versionning everything

parent cf54973e
library(reshape2)
library(scales)
initImage <- function(name, extension) {
if(extension=="svg")
svg(filename=paste(name,".svg", sep=""))
else
pdf(file=paste(name,".pdf", sep=""))
}
getMemoryUsed <- function(data, mmname, cloningname) {
value = data[data$MetamodelName==mmname & data$CloningTechnique==cloningname, c('MemoryUsed')]
return(value)
}
computeMemoryGainCreator <- function(rawdata, cloningName) {
numberClonesColumn = which(colnames(rawdata)=="NumberOfClones")
totalMemoryColumn = which(colnames(rawdata)=="MemoryUsed")
nameColumn = which(colnames(rawdata)=="MetamodelName")
computeMemoryRatio <- function(row) {
totalMemory <- as.integer(row[totalMemoryColumn])
name <- as.character(row[nameColumn])
otherCloningMemory = getMemoryUsed(rawdata, name, cloningName)
return (1-totalMemory/otherCloningMemory)
}
# We return the function that can process each row
return(computeMemoryRatio)
}
preprocessData <- function (rawdata) {
# We merge the columns cloningtechnique and light (to create "LightDeep" for instance)
rawdata$CloningTechnique = paste(rawdata$Light, rawdata$CloningTechnique, sep="")
# We compute the gain compared to three out of four techniques
rawdataWithoutLabels <- matrix(as.matrix(rawdata), ncol = ncol(rawdata), dimnames = NULL)
rawdata$GainDeep = apply(rawdataWithoutLabels,1,computeMemoryGainCreator(rawdata, 'Deep'))
rawdata$GainLightDeep = apply(rawdataWithoutLabels,1,computeMemoryGainCreator(rawdata, 'LightDeep'))
rawdata$GainMutClassOnly = apply(rawdataWithoutLabels,1,computeMemoryGainCreator(rawdata, 'MutClassOnly'))
# Filtering required columns and required lines
#filtered = rawdata[, c(measure,'CloningTechnique', variable, 'MetamodelName', 'NumberOfClones')]
# Getting the list of cloning techniques, in the right order
techniques = unique(rawdata$CloningTechnique)
# Enforcing the order of the cloning techniques column
# https://stackoverflow.com/questions/19710986/how-to-make-acast-preserve-order-of-variable-in-reshape2
rawdata$CloningTechnique = factor(rawdata$CloningTechnique, techniques)
return(rawdata)
}
#
# Creates a barplot that compares a given metamodel on one aspect (memory or time) for numerous "number of clones" values
#
plotNumberOfClones <- function(rawdata, metamodelname, minvalue, maxvalue, measure, title){
prefiltered = preprocessData(rawdata,measure,'NumberOfClones')
filtered = prefiltered[prefiltered$MetamodelName==metamodelname & prefiltered$NumberOfClones<=maxvalue & prefiltered$NumberOfClones>=minvalue, c(measure,'CloningTechnique', 'NumberOfClones')]
# Transform the table nicely: NumberOfClones becomes lines, and CloningTechniques columns
# Means that we want to compare "cloningtechniques" regarding "memory" for each "numberofclones"
result = dcast(filtered,CloningTechnique~NumberOfClones,value.var=measure)
# We store the column with the name of the cloning techniques, for the legend, and we delete it
legendc = result$CloningTechnique
result$CloningTechnique = NULL
# We plot with bars, and we put a legend
name = paste(metamodelname,"_",minvalue,"-",maxvalue,"_clones_",measure, sep="")
formats = c("svg")#,"pdf")
for (format in formats) {
initImage(name,format)
barplot(as.matrix(result), main=title, xlab= "Number of clones", ylab=measure,beside=TRUE, col=rainbow(length(legendc)))
legend("topleft", as.vector(legendc), cex=1, bty="n", fill=rainbow(length(legendc)));
}
return(result)
}
plotStuff <- function(rawdata, measure, variable, numberOfClones, cloning, maxX, maxY, title) {
myxlim = NULL
if (maxX > 0) {
myxlim = c(0,maxX)
}
myylim = NULL
if (maxY > 0) {
myylim = c(0,maxY)
}
myxlab=variable
if (variable == "MutClassCompShareableClassesRatio") {
myxlab = "ratio of classes tagged completely shareable \n(objectsSharing tagger)"
}
if (variable == "DeepMeanShareablePropertiesInShareableClasses") {
myxlab = "properties tagged shareable per class tagged completely shareable \n(noObjectsSharing tagger)"
}
if (variable == "MutClassMeanShareablePropertiesInShareableClasses") {
myxlab = "amount of properties tagged shareable per class tagged completely shareable \n(objectsSharing tagger)"
}
myylab=measure
if (measure == "GainDeep") {
myylab = "memory gain over Deep"
}
if (measure == "GainLightDeep") {
myylab = "memory gain over ShareProperties"
}
if (measure == "GainMutClassOnly") {
myylab = "memory gain over ShareObjects"
}
data = preprocessData(rawdata)
mutclassonly = data[data$CloningTechnique==cloning,]
initImage(paste(cloning,measure),'svg')
plot(mutclassonly[,c(variable)], mutclassonly[,c(measure)],ylim=myylim, pch=15, xlab=myxlab, xlim=myxlim, ylab=myylab, yaxt="n", main=title)
axis(2, at=pretty(mutclassonly[,c(measure)]), lab=paste0(pretty(mutclassonly[,c(measure)]) * 100,"%"), las=TRUE)
}
arg = commandArgs(TRUE)
# Parsing CSV file
myrawdata = read.csv(arg)
#plotNumberOfClones(myrawdata, "youpitest1", 0, 10, 'MemoryUsed')
#plotNumberOfClones(myrawdata, "youpitest1", 100, 2000, 'MemoryUsed')
#plotNumberOfClones(myrawdata, "youpitest1", 1000, 10000, 'MemoryUsed')
#plotNumberOfClones(myrawdata, "youpitest1", 0, 10, 'TimeSpent')
#plotNumberOfClones(myrawdata, "youpitest1", 100, 2000, 'TimeSpent')
#plotNumberOfClones(myrawdata, "youpitest1", 1000, 10000, 'TimeSpent')
#plotNumberOfClones(myrawdata, "youpitest1", 1000, 1000, 'MemoryUsed')
#plotNumberOfClones(myrawdata, "youpitest1", 1000, 1000, 'TimeSpent')
#plotNumberOfClones(myrawdata, "youpitest1", 100, 2000, 'MemoryUsed', "Well designed MM")
#plotNumberOfClones(myrawdata, "youpitest1", 1000, 10000, 'MemoryUsed', "Well designed MM")
#plotNumberOfClones(myrawdata, "youpitest2", 100, 2000, 'MemoryUsed', "Well designed MM")
#plotNumberOfClones(myrawdata, "youpitest2", 1000, 10000, 'MemoryUsed', "Well designed MM")
#plotNumberOfClones(myrawdata, "youpitest2", 0, 10, 'TimeSpent', "Well designed MM")
#plotNumberOfClones(myrawdata, "youpitest2", 100, 2000, 'TimeSpent', "Well designed MM")
#plotNumberOfClones(myrawdata, "youpitest2", 1000, 10000, 'TimeSpent', "Well designed MM")
#plotNumberOfClones(myrawdata, "youpitest1", 0, 10, 'MemoryUsed', "")
#plotNumberOfClones(myrawdata, "youpitest2", 0, 10, 'MemoryUsed', "")
#plotNumberOfClones(myrawdata, "youpitest3", 0, 10, 'MemoryUsed', "")
#plotNumberOfClones(myrawdata, "youpitest1", 0, 10, 'GainDeep', "")
#plotNumberOfClones(myrawdata, "youpitest2", 0, 10, 'GainDeep', "")
#plotNumberOfClones(myrawdata, "youpitest3", 0, 10, 'GainDeep', "")
plotStuff(
myrawdata,
'GainDeep',
'MutClassCompShareableClassesRatio',
'10',
'MutClassOnly',
1, 1,
"Memory gain of ShareObjects compared to Deep\nwith varying ratio of classes tagged completely shareable")
plotStuff(myrawdata, 'GainLightDeep', 'MutClassCompShareableClassesRatio', '10', 'LightMutClassOnly', 1, 1, "Memory gain of ShareBoth compared to ShareProperties \nwith varying ratio of classes tagged completely shareable")
plotStuff(myrawdata, 'GainDeep', 'DeepMeanShareablePropertiesInShareableClasses', '10', 'LightDeep', -1, 1, "Memory gain of ShareProperties compared to Deep \n with varying amount of properties tagged shareable \n per class tagged completely shareable")
plotStuff(myrawdata, 'GainMutClassOnly', 'MutClassMeanShareablePropertiesInShareableClasses', '10', 'LightMutClassOnly', -1, 1, "Memory gain of ShareBoth compared to ShareObjects \n with varying amount of properties tagged shareable \n per class tagged completely shareable")
library(reshape2)
library(scales)
initImage <- function(name, extension) {
if(extension=="svg")
svg(filename=paste(name,".svg", sep=""))
else
pdf(file=paste(name,".pdf", sep=""))
}
getMemoryUsed <- function(data, mmname, cloningname) {
value = data[data$MetamodelName==mmname & data$CloningTechnique==cloningname, c('MemoryUsed')]
return(value)
}
computeMemoryGainCreator <- function(rawdata, cloningName) {
numberClonesColumn = which(colnames(rawdata)=="NumberOfClones")
totalMemoryColumn = which(colnames(rawdata)=="MemoryUsed")
nameColumn = which(colnames(rawdata)=="MetamodelName")
computeMemoryRatio <- function(row) {
totalMemory <- as.integer(row[totalMemoryColumn])
name <- as.character(row[nameColumn])
otherCloningMemory = getMemoryUsed(rawdata, name, cloningName)
return (1-totalMemory/otherCloningMemory)
}
# We return the function that can process each row
return(computeMemoryRatio)
}
preprocessData <- function (rawdata) {
# We merge the columns cloningtechnique and light (to create "LightDeep" for instance)
rawdata$CloningTechnique = paste(rawdata$Light, rawdata$CloningTechnique, sep="")
# We compute the gain compared to three out of four techniques
rawdataWithoutLabels <- matrix(as.matrix(rawdata), ncol = ncol(rawdata), dimnames = NULL)
rawdata$GainDeep = apply(rawdataWithoutLabels,1,computeMemoryGainCreator(rawdata, 'Deep'))
rawdata$GainLightDeep = apply(rawdataWithoutLabels,1,computeMemoryGainCreator(rawdata, 'LightDeep'))
rawdata$GainMutClassOnly = apply(rawdataWithoutLabels,1,computeMemoryGainCreator(rawdata, 'MutClassOnly'))
# Filtering required columns and required lines
#filtered = rawdata[, c(measure,'CloningTechnique', variable, 'MetamodelName', 'NumberOfClones')]
# Getting the list of cloning techniques, in the right order
techniques = unique(rawdata$CloningTechnique)
# Enforcing the order of the cloning techniques column
# https://stackoverflow.com/questions/19710986/how-to-make-acast-preserve-order-of-variable-in-reshape2
rawdata$CloningTechnique = factor(rawdata$CloningTechnique, techniques)
return(rawdata)
}
#
# Creates a barplot that compares a given metamodel on one aspect (memory or time) for numerous "number of clones" values
#
plotNumberOfClones <- function(rawdata, metamodelname, minvalue, maxvalue, measure, title){
prefiltered = preprocessData(rawdata,measure,'NumberOfClones')
filtered = prefiltered[prefiltered$MetamodelName==metamodelname & prefiltered$NumberOfClones<=maxvalue & prefiltered$NumberOfClones>=minvalue, c(measure,'CloningTechnique', 'NumberOfClones')]
# Transform the table nicely: NumberOfClones becomes lines, and CloningTechniques columns
# Means that we want to compare "cloningtechniques" regarding "memory" for each "numberofclones"
result = dcast(filtered,CloningTechnique~NumberOfClones,value.var=measure)
# We store the column with the name of the cloning techniques, for the legend, and we delete it
legendc = result$CloningTechnique
result$CloningTechnique = NULL
# We plot with bars, and we put a legend
name = paste(metamodelname,"_",minvalue,"-",maxvalue,"_clones_",measure, sep="")
formats = c("svg")#,"pdf")
for (format in formats) {
initImage(name,format)
barplot(as.matrix(result), main=title, xlab= "Number of clones", ylab=measure,beside=TRUE, col=rainbow(length(legendc)))
legend("topleft", as.vector(legendc), cex=1, bty="n", fill=rainbow(length(legendc)));
}
return(result)
}
plotStuff <- function(rawdata, measure, variable, numberOfClones, cloning, maxX, maxY, title) {
myxlim = NULL
if (maxX > 0) {
myxlim = c(0,maxX)
}
myylim = NULL
if (maxY > 0) {
myylim = c(0,maxY)
}
myxlab=variable
if (variable == "MutClassCompShareableClassesRatio") {
myxlab = "ratio of classes tagged completely shareable \n(objectsSharing tagger)"
}
if (variable == "DeepMeanShareablePropertiesInShareableClasses") {
myxlab = "properties tagged shareable per class tagged completely shareable \n(noObjectsSharing tagger)"
}
if (variable == "MutClassMeanShareablePropertiesInShareableClasses") {
myxlab = "amount of properties tagged shareable per class tagged completely shareable \n(objectsSharing tagger)"
}
myylab=measure
if (variable == "GainDeep") {
myylab = "memory gain over Deep"
}
if (variable == "GainLightDeep") {
myylab = "memory gain over ShareProperties"
}
if (variable == "GainMutClassOnly") {
myylab = "memory gain over ShareObjects"
}
data = preprocessData(rawdata)
mutclassonly = data[data$CloningTechnique==cloning,]
initImage(paste(cloning,measure),'svg')
plot(mutclassonly[,c(variable)], mutclassonly[,c(measure)],ylim=myylim, pch=15, xlab=myxlab, xlim=myxlim, ylab=myylab, yaxt="n", main=title)
axis(2, at=pretty(mutclassonly[,c(measure)]), lab=paste0(pretty(mutclassonly[,c(measure)]) * 100,"%"), las=TRUE)
}
arg = commandArgs(TRUE)
# Parsing CSV file
myrawdata = read.csv(arg)
#plotNumberOfClones(myrawdata, "youpitest1", 0, 10, 'MemoryUsed')
#plotNumberOfClones(myrawdata, "youpitest1", 100, 2000, 'MemoryUsed')
#plotNumberOfClones(myrawdata, "youpitest1", 1000, 10000, 'MemoryUsed')
#plotNumberOfClones(myrawdata, "youpitest1", 0, 10, 'TimeSpent')
#plotNumberOfClones(myrawdata, "youpitest1", 100, 2000, 'TimeSpent')
#plotNumberOfClones(myrawdata, "youpitest1", 1000, 10000, 'TimeSpent')
#plotNumberOfClones(myrawdata, "youpitest1", 1000, 1000, 'MemoryUsed')
#plotNumberOfClones(myrawdata, "youpitest1", 1000, 1000, 'TimeSpent')
#plotNumberOfClones(myrawdata, "youpitest1", 100, 2000, 'MemoryUsed', "Well designed MM")
#plotNumberOfClones(myrawdata, "youpitest1", 1000, 10000, 'MemoryUsed', "Well designed MM")
#plotNumberOfClones(myrawdata, "youpitest2", 100, 2000, 'MemoryUsed', "Well designed MM")
#plotNumberOfClones(myrawdata, "youpitest2", 1000, 10000, 'MemoryUsed', "Well designed MM")
#plotNumberOfClones(myrawdata, "youpitest2", 0, 10, 'TimeSpent', "Well designed MM")
#plotNumberOfClones(myrawdata, "youpitest2", 100, 2000, 'TimeSpent', "Well designed MM")
#plotNumberOfClones(myrawdata, "youpitest2", 1000, 10000, 'TimeSpent', "Well designed MM")
#plotNumberOfClones(myrawdata, "youpitest1", 0, 10, 'MemoryUsed', "")
#plotNumberOfClones(myrawdata, "youpitest2", 0, 10, 'MemoryUsed', "")
#plotNumberOfClones(myrawdata, "youpitest3", 0, 10, 'MemoryUsed', "")
#plotNumberOfClones(myrawdata, "youpitest1", 0, 10, 'GainDeep', "")
#plotNumberOfClones(myrawdata, "youpitest2", 0, 10, 'GainDeep', "")
#plotNumberOfClones(myrawdata, "youpitest3", 0, 10, 'GainDeep', "")
plotStuff(
myrawdata,
'GainDeep',
'MutClassCompShareableClassesRatio',
'10',
'MutClassOnly',
1, 1,
"Memory gain of ShareObjects compared to Deep\nwith varying ratio of classes tagged completely shareable")
plotStuff(myrawdata, 'GainLightDeep', 'MutClassCompShareableClassesRatio', '10', 'LightMutClassOnly', 1, 1, "Memory gain of ShareBoth compared to ShareProperties \nwith varying ratio of classes tagged completely shareable")
plotStuff(myrawdata, 'GainDeep', 'DeepMeanShareablePropertiesInShareableClasses', '10', 'LightDeep', -1, 1, "Memory gain of ShareProperties compared to Deep \n with varying amount of properties tagged shareable \n per class tagged completely shareable")
plotStuff(myrawdata, 'GainMutClassOnly', 'MutClassMeanShareablePropertiesInShareableClasses', '10', 'LightMutClassOnly', -1, 1, "Memory gain of ShareBoth compared to ShareObjects \n with varying amount of properties tagged shareable \n per class tagged completely shareable")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment