JMeterVariables vars = getVariables(); int sum = 0; String varName = ((CompoundVariable) values[values.length - 1]).execute(); for (int i = 0; i < values.length - 1; i++) { sum += Integer.parseInt(((CompoundVariable) values[i]).execute()); } try { sum += Integer.parseInt(varName); varName = null; // there is no variable name } catch (NumberFormatException ignored) { } String totalString = Integer.toString(sum); if (vars != null && varName != null){// vars will be null on TestPlan vars.put(varName.trim(), totalString); } return totalString;
JMeterVariables vars = getVariables(); long sum = 0; String varName = ((CompoundVariable) values[values.length - 1]).execute().trim(); for (int i = 0; i < values.length - 1; i++) { sum += Long.parseLong(((CompoundVariable) values[i]).execute()); } try { sum += Long.parseLong(varName); varName = null; // there is no variable name } catch (NumberFormatException ignored) { } String totalString = Long.toString(sum); if (vars != null && varName != null && varName.length() > 0){// vars will be null on TestPlan vars.put(varName, totalString); } return totalString;
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/functions/IntSum.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/functions/LongSum.java
Method name: String execute(SampleResult, Sampler) Method name: String execute(SampleResult, Sampler)
Number of AST nodes: 12 Number of AST nodes: 12
1
JMeterVariables vars = getVariables();
1
JMeterVariables vars = getVariables();
2
		int sum = 0;
2
		long sum = 0;
3
		String varName = ((CompoundVariable) values[values.length - 1]).execute();
3
		String varName = ((CompoundVariable) values[values.length - 1]).execute().trim();
4
		for (int i = 0; i < values.length - 1; i++) {
4
		for (int i = 0; i < values.length - 1; i++) {
5
			sum += Integer.parseInt(((CompoundVariable) values[i]).execute());
5
			sum += Long.parseLong(((CompoundVariable) values[i]).execute());
6
		}
6
		}
7
        try {
7
        try {
8
            sum += Integer.parseInt(varName);
8
            sum += Long.parseLong(varName);
9
            varName = null; // there is no variable name
9
            varName = null; // there is no variable name
10
        } catch (NumberFormatException ignored) {
10
        } catch (NumberFormatException ignored) {
11
        }
11
        }
12
        
12
        
13
String totalString = Integer.toString(sum);
13
		String totalString = Long.toString(sum);
14
		if (vars != null && varName != null){// vars will be null on TestPlan
14
		if (vars != null && varName != null && varName.length() > 0){// vars will be null on TestPlan
15
			vars.put(varName.trim(), totalString);
15
			vars.put(varName, totalString);
16
		}
16
		}
17
		return totalString;
17
		return totalString;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.7
Clones locationClones are in different classes having the same super class
Number of node comparisons34
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)1.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    JMeterVariables vars = getVariables();
    1
    JMeterVariables vars = getVariables();
                                
    2
    long sum = 0;
    2
    int sum = 0;
                              
                                                                                                                                                                      
    3
    String varName = ((CompoundVariable)values[values.length - 1]).execute().trim();
    3
    String varName = ((CompoundVariable)values[values.length - 1]).execute();
                                                                                                                                                        
    4
    for (int i = 0; i < values.length - 1; i++)
    4
    for (int i = 0; i < values.length - 1; i++)
                                                                                                                                    
    5
    sum += Long.parseLong(((CompoundVariable)values[i]).execute());
    Preondition Violations
    Unmatched statement sum+=Long.parseLong(((CompoundVariable)values[i]).execute()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    sum += Long.parseLong(((CompoundVariable)values[i]).execute());
    5
    sum += Integer.parseInt(((CompoundVariable)values[i]).execute());
    5
    sum += Integer.parseInt(((CompoundVariable)values[i]).execute());
    Preondition Violations
    Unmatched statement sum+=Integer.parseInt(((CompoundVariable)values[i]).execute()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                        
    6
    try
    6
    try
                                                                    
    7
    sum += Long.parseLong(varName);
    Preondition Violations
    Unmatched statement sum+=Long.parseLong(varName); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    7
    sum += Long.parseLong(varName);
    7
    sum += Integer.parseInt(varName);
    7
    sum += Integer.parseInt(varName);
    Preondition Violations
    Unmatched statement sum+=Integer.parseInt(varName); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                                        
    8
    varName = null;
    8
    varName = null;
    Precondition Violations (5)
    Row Violation
    1Unmatched statement sum+=Long.parseLong(((CompoundVariable)values[i]).execute()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement sum+=Integer.parseInt(((CompoundVariable)values[i]).execute()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement sum+=Long.parseLong(varName); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    4Unmatched statement sum+=Integer.parseInt(varName); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    5Clone fragment #1 returns variables i, vars, varName , while Clone fragment #2 returns variables i, vars, varName