3

I am doing automation. But my code working takes more time. I am taking index value from deDupStringList array. for click on the gui application. I read the data from back end. This is my entire number sequence:

[1,2,3,1.5,5,6,7,4,5,6,7,12,13,1.75,4.5,16,17,6.5,7,12,13,16,17,24,25,14.50,14.51,6.75,7,12,13,14.5,14.51,16,17,24,25,38,39,31.5,41]

seqDBNo contains entire data... whenever 3>1.5 or 7>4 13>1.75 so I am going through this method. This is for insert before operation. So my i value is 3 then 7 ... In this arrli array contain first [1,2,3], then current sequence number is 1.5 and then I compare 1.5 with others, so there I am taking immediate grater value that is 2.. this is how my code works.. but it is very slow ... please help me to improve the speed of my code.

for(int i=0;i<alEvents.size();i++) 
        {
            sequenceNo = Double.parseDouble(alEvents.get(i).sequenceNumber.trim());
            seqDBNo.add(sequenceNo);
            
        }   
public static void insertBeforeMethod(){
int specificIndex=0;
        Double greate = null;
        double sequenceNo = Double.parseDouble(alEvents.get(i).sequenceNumber.trim());  
        List<Double> arrli = new ArrayList<Double>(); //1,2,3 --- >1.5
        
        for(int dbseq=0;dbseq<i;dbseq++)
        {
            arrli.add(seqDBNo.get(dbseq));

        }
            List<Double> deDupStringList = new ArrayList<>(new HashSet<>(arrli));//remove duplicate values
            Collections.sort(deDupStringList); //1,2,3
                
                for(int db=0;db<deDupStringList.size();db++)
                {
                    
                if(deDupStringList.get(db)>sequenceNo) // 2>1.5
                {
                    greate=deDupStringList.get(db);
                    break;
                }
                }

        specificIndex=deDupStringList.indexOf(greate);
}

1 Answer 1

1

Sounds like you'd do better using property-based testing, like with junit-quickcheck for java. You'd not just be more likely to cover a lot more cases, chances are your code would run faster too. I know we're not supposed to link :-), but still here's a little intro to the concept https://www.ontestautomation.com/an-introduction-to-property-based-testing-with-junit-quickcheck/ besides whatever you can google..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.