According to the code provided, there are a few hypotheses that I might think of.
Since you said that you are not getting any output I would formulate that this code might not even being executed. The reason for my statement relies on the following two pieces of your code:
//start time
int scrollStartTime = 0 ;
//end time
int scrollEndTime = 0 ;
(...)
//get the time gap take to change images
int scrollerTime = scrollEndTime - scrollStartTime ;
System.out.println(scrollerTime);
This means that even if the list is empty and your for loop is not run you at least would see the number zero (0) provided in your terminal.
Lets assume for now that indeed the zero (0) appears in your terminal but you didn't noticed, so the issue might rely on the for loop. The reason why is that you're are stating that you have a list of 2 elements (considering that indeed your list is not empty) but the time to iterate a 2 element list is almost instant, so there is a high change that your code already finished iterating without any of the items even being selected, this means that none of the if statements is entered.
Since I don't have the full insight it is hard to provide you a concrete answer but you might want to change your logic to wait for when the specific event occurs and capture its time (in this case the specific button is selected). Below I try to provide an example that possibly may solve your problem and give you an answer to the time that it takes to move the carousel.
Please note that the code provided below doesn't follow the correct practice for coding a good automation and it is only to provide a quick example of what you might do, so consider adapting it to a correct practice.
//element selectors
@FindBy(xpath = "//div[@id='carouselExampleCaptions']")
private WebElement carouselElementContainer;
@FindBy(xpath = "//div[@id='carouselExampleCaptions']//li")
private List<WebElement> carouselElements;
(...)
public void deltaTimeForCarouselElementSelect(){
//site with carousel that automatically switch images
driver.get("https://getbootstrap.com/docs/4.0/components/carousel/");
wait.until(ExpectedConditions.visibilityOf(carouselElementContainer));
wait.until(ExpectedConditions.attributeContains(carouselElements.get(0), "class", "active"));
double initialTime = getCurrentMilliSecTime();
System.out.printf("Time for first event: %s milliseconds %n", initialTime);
wait.until(ExpectedConditions.attributeContains(carouselElements.get(carouselElements.size() - 1), "class", "active"));
double finalTime = getCurrentMilliSecTime();
System.out.printf("Time for last event: %s milliseconds %n", finalTime);
long DeltaInMilli = finalTime - initialTime;
System.out.printf("Time that took between the two events - %f milliseconds %n", DeltaInMilli);
}
private long getCurrentMilliSecTime(){
Date date = new Date();
return date.getTime();
}
Running this method will provide a similar output as the one displayed below:
Time for first event: 1.654638603088E12 milliseconds
Time for last event: 1.654638613128E12 milliseconds
Time that took between the two events - 10040.000000 milliseconds