Skip to content

Commit

Permalink
added synth bench
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniilStepanov committed May 10, 2024
1 parent d2e731f commit affad7f
Show file tree
Hide file tree
Showing 5,595 changed files with 6,279 additions and 300,115 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
17 changes: 17 additions & 0 deletions src/main/java/org/owasp/benchmark/helpers/ArrayHolder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.owasp.benchmark.helpers;

public class ArrayHolder {
private String[] values;

public ArrayHolder(String value) {
this(new String[] {value, "A", "B"}); // Динамическая инициализация
}

public ArrayHolder(String[] initialValues) {
this.values = initialValues;
}

public String[] getValues() {
return values;
}
}
9 changes: 9 additions & 0 deletions src/main/java/org/owasp/benchmark/helpers/BaseClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.owasp.benchmark.helpers;

public class BaseClass {
public String baseValue;

public BaseClass(String value) {
this.baseValue = value;
}
}
15 changes: 15 additions & 0 deletions src/main/java/org/owasp/benchmark/helpers/CollectionHolder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.owasp.benchmark.helpers;

import java.util.*;

public class CollectionHolder {
public List<String> list;

public CollectionHolder(String value) {
this(Arrays.asList(value, "EMPTY"));
}

private CollectionHolder(List<String> initialList) {
this.list = new ArrayList<>(initialList);
}
}
17 changes: 17 additions & 0 deletions src/main/java/org/owasp/benchmark/helpers/Configurator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.owasp.benchmark.helpers;

public class Configurator {
private String configurationValue;

public Configurator(int value) {
this(value, "EMPTY"); // Значение по умолчанию
}

public Configurator(int value, String configurationValue) {
this.configurationValue = value > 50 ? "EMPTY" : configurationValue;
}

public String getConfigurationValue() {
return configurationValue;
}
}
29 changes: 29 additions & 0 deletions src/main/java/org/owasp/benchmark/helpers/ConstructorChains.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.owasp.benchmark.helpers;

public class ConstructorChains {

private final int number;
private final String text;

public ConstructorChains(String text) {
this(1, text);
}

public ConstructorChains(int number, String text) {
this.number = number;
if (number == 1) {
this.text = text;
} else {
this.text = "empty";
}
}

public String getText(int n) {
if (n == 1) {
return text;
} else {
return "";
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.owasp.benchmark.helpers;

public class ConstructorDelegation {
private String a, b, c;

public ConstructorDelegation(String value) {
this(value, " ADD "); // Default values
}

private ConstructorDelegation(String a, String b) {
this(a, b, a + b); // Calculate c based on a and b
}

private ConstructorDelegation(String a, String b, String c) {
this.a = a;
this.b = b;
this.c = c;
}

public String getC() {
return c;
}
}
13 changes: 13 additions & 0 deletions src/main/java/org/owasp/benchmark/helpers/DerivedClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.owasp.benchmark.helpers;

public class DerivedClass extends BaseClass {
public DerivedClass() {
super("EMPTY");
this.baseValue += "DerivedClass";
}

public DerivedClass(String value) {
super(value);
this.baseValue += "FROM";
}
}
17 changes: 17 additions & 0 deletions src/main/java/org/owasp/benchmark/helpers/FactoryExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.owasp.benchmark.helpers;

public class FactoryExample {
public String val;

private FactoryExample(String val) {
if (val.contains("USERS")) {
this.val = val;
} else {
this.val = "EMPTY";
}
}

public static FactoryExample createInstance(String value) {
return new FactoryExample(value);
}
}
23 changes: 23 additions & 0 deletions src/main/java/org/owasp/benchmark/helpers/InstanceInitializer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.owasp.benchmark.helpers;

import java.util.ArrayList;
import java.util.List;

public class InstanceInitializer {

public static String value;

private List<String> list;

{
list = new ArrayList<>();
list.add(value);
}

public String getValue() {
return list.get(0);
}

public InstanceInitializer() {
}
}
16 changes: 16 additions & 0 deletions src/main/java/org/owasp/benchmark/helpers/LazyInitialized.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.owasp.benchmark.helpers;

public class LazyInitialized {
private volatile String value;

public String getValue(String val) {
if (value == null) {
synchronized (this) {
if (value == null) {
value = "~[String]~";
}
}
}
return value;
}
}
5 changes: 5 additions & 0 deletions src/main/java/org/owasp/benchmark/helpers/Mode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.owasp.benchmark.helpers;

public enum Mode {
DEFAULT, CUSTOM
}
17 changes: 17 additions & 0 deletions src/main/java/org/owasp/benchmark/helpers/ModeSelector.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.owasp.benchmark.helpers;

public class ModeSelector {
private Mode mode;

public ModeSelector() {
this(Mode.DEFAULT);
}

public ModeSelector(Mode mode) {
this.mode = mode;
}

public Mode getMode() {
return mode;
}
}
19 changes: 19 additions & 0 deletions src/main/java/org/owasp/benchmark/helpers/OptionalHolder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.owasp.benchmark.helpers;

import java.util.Optional;

public class OptionalHolder {
private Optional<String> optionalValue;

public OptionalHolder(String value) {
this(Optional.ofNullable(value));
}

private OptionalHolder(Optional<String> value) {
this.optionalValue = value;
}

public String getOptionalValue() {
return optionalValue.orElse("EMPTY");
}
}
23 changes: 23 additions & 0 deletions src/main/java/org/owasp/benchmark/helpers/OuterClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.owasp.benchmark.helpers;

public class OuterClass {
private InnerClass innerObject;
private String value;

public OuterClass(String value) {
this.innerObject = this.new InnerClass(value);
}

public InnerClass getInnerObject() {
return innerObject;
}


public class InnerClass {
public String innerValue;

InnerClass(String value) {
this.innerValue = value;
}
}
}
18 changes: 18 additions & 0 deletions src/main/java/org/owasp/benchmark/helpers/UtilityClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.owasp.benchmark.helpers;

public class UtilityClass {
public static String DEFAULT_VALUE = "EMPTY";
public String value;

public UtilityClass() {
this(initialValue());
}

private UtilityClass(String value) {
this.value = value;
}

private static String initialValue() {
return DEFAULT_VALUE;
}
}
105 changes: 0 additions & 105 deletions src/main/java/org/owasp/benchmark/testcode/BenchmarkTest00001.java

This file was deleted.

Loading

0 comments on commit affad7f

Please sign in to comment.