Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
#
# Zhu_et_al-2014.R, 5 Mar 20
#
# Data from:
# An analysis of programming language statement frequency in {C}, {C++}, and {Java} source code
# Xiaoyan Zhu and E. James Whitehead Jr. and Caitlin Sadowski and Qinbao Song
#
# Example from:
# Evidence-based Software Engineering: based on the publicly available data
# Derek M. Jones
#
# TAG C_statement C++_statement Java_statement if_frequency assignment_frequency declaration_frequency loop_frequency
source("ESEUR_config.r")
par(mar=MAR_default-c(1.7, 1.7, 0.7, 0.5))
# Number,Project,File,TotalLines,ExecuteLines,FunctionCall,FunctionCall_percent,If,If_percent,Assignment,Assignment_percent,Function,Function_percent,FunctionDeclaration,FunctionDeclaration_percent,Loop,Loop_percent,DeclarationStatement,DeclarationStatement_percent,Declaration,Declaration_percent,ExpressionStatement,ExpressionStatement_percent,Expression,Expression_percent,ParameterList,ParameterList_percent,Parameter,Parameter_percent,ArgumentList,ArgumentList_percent,Argument,Argument_percent,Block,Block_percent,Continue,Continue_percent,Break,Break_percent,Return,Return_percent,For,For_percent,Else,Else_percent,While,While_percent,Do,Do_percent,Switch,Switch_percent,Case,Case_percent,LocalFunctionCall,LibFunctionCall,GetterSetterCall,ZeroOperatorAssign,ZeroOpCallAssign,ConstAssign,DeclInDeclStmt,DeclInFor,ParamDecl,Struct,Struct_percent,Gogo,Goto_percent,Label,Label_percent
stmt_c=read.csv(paste0(ESEUR_dir, "sourcecode/TotalStatistics_line_c.csv.xz"), as.is=TRUE)
stmt_cpp=read.csv(paste0(ESEUR_dir, "sourcecode/TotalStatistics_line_cpp.csv.xz"), as.is=TRUE)
stmt_java=read.csv(paste0(ESEUR_dir, "sourcecode/TotalStatistics_line_java.csv.xz"), as.is=TRUE)
pal_col=rainbow(3)
plot_stmt=function(stmt_str)
{
c_density=density(getElement(stmt_c, paste0(stmt_str, "_percent")))
cpp_density=density(getElement(stmt_cpp, paste0(stmt_str, "_percent")))
java_density=density(getElement(stmt_java, paste0(stmt_str, "_percent")))
max_x=max(c(c_density$x, cpp_density$x, java_density$x))
max_y=max(c(c_density$y, cpp_density$y, java_density$y))
plot(c_density, col=pal_col[1],
main="", xlab="", ylab="",
xaxs="i", yaxs="i",
xlim=c(0, max_x), ylim=c(0, max_y))
lines(cpp_density, col=pal_col[2])
lines(java_density, col=pal_col[3])
text(max_x, max_y/1.1, paste0("\n", stmt_str), pos=2, cex=1.2)
}
par(mfcol=c(3, 3))
plot_stmt("Function")
plot_stmt("If")
plot_stmt("Else")
plot_stmt("Assignment")
plot_stmt("Declaration")
plot_stmt("Break")
plot_stmt("Return")
plot_stmt("While")
plot_stmt("Switch")