Skip to content

Commit

Permalink
Change Random to SecureRandom
Browse files Browse the repository at this point in the history
In order to get a true Random Random
was changed to SecureRandom and revised
seed to be a byte array

Change-Id: I241d35dcdc52f37ada3181794fda30806df6769c
Signed-off-by: Estelle Foisy <estelle.foisy@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/199348
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
  • Loading branch information
Estelle Foisy authored and bhufmann committed Jan 13, 2023
1 parent c6a15dc commit 3a7d2de
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Expand Up @@ -14,7 +14,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Random;
import java.security.SecureRandom;

import org.eclipse.tracecompass.incubator.internal.xaf.ui.statemachine.StateMachineInstance.InstanceStepInformation;

Expand Down Expand Up @@ -50,7 +50,7 @@ public IsiSampleIterator(Collection<InstanceStepInformation> collection) {
size = (int)sample;
count = size;
iterator = new Iterator<InstanceStepInformation>() {
private Random rand = new Random();
private SecureRandom rand = new SecureRandom();
private ArrayList<InstanceStepInformation> isiList = new ArrayList<>(collection);

@Override
Expand Down
Expand Up @@ -12,7 +12,7 @@
package org.eclipse.tracecompass.incubator.internal.xaf.core.statemachine.variable.utils;

import java.util.Iterator;
import java.util.Random;
import java.security.SecureRandom;

import org.eclipse.tracecompass.incubator.internal.xaf.ui.statemachine.StateMachineReport;

Expand All @@ -22,7 +22,7 @@ class RandomCombinationsIterator implements Iterator<int[]> {
private final int n, k;
private Integer count = null;
private int[] origin, solution;
private Random rand = new Random();
private SecureRandom rand = new SecureRandom();

public RandomCombinationsIterator(int n, int k) {
this.n = n;
Expand Down
Expand Up @@ -13,7 +13,7 @@

import java.util.Arrays;
import java.util.Iterator;
import java.util.Random;
import java.security.SecureRandom;
import java.util.Set;
import java.util.TreeSet;

Expand All @@ -24,7 +24,7 @@ class RandomCombinationsIteratorUnique implements Iterator<int[]> {
private final int n, k;
private Integer count = null;
private int[] origin, solution;
private Random rand = new Random();
private SecureRandom rand = new SecureRandom();
private Set<Integer> used = new TreeSet<>();

public RandomCombinationsIteratorUnique(int n, int k) {
Expand Down
Expand Up @@ -20,7 +20,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Random;
import java.security.SecureRandom;

import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.Performance;
Expand Down Expand Up @@ -66,7 +66,7 @@ public abstract class CallStackAndGraphBenchmark {
private static final String TEST_CALLGRAPH_QUERY = "CallGraph Query (%s)";
private static final String TEST_CALLGRAPH_GROUPBY = "CallGraph Group By (%s)";

private static final long SEED = 473892745896L;
private static final byte[] SEED = {0x45, 0x73, 0x74, 0x65, 0x6c, 0x6c, 0x65};

private static final int LOOP_COUNT = 5;

Expand Down Expand Up @@ -133,7 +133,7 @@ public void runCpuBenchmark() throws TmfTraceException {
long delta = endTime - startTime;

// Get partial callgraphs
Random randomGenerator = new Random(SEED);
SecureRandom randomGenerator = new SecureRandom(SEED);
callgraphQueryPm.start();
for (int j = 0; j < 50; j++) {
long time0 = Math.abs(randomGenerator.nextLong()) % delta;
Expand Down

0 comments on commit 3a7d2de

Please sign in to comment.