If we have switched to next second:
<li>
<ul>Updates time</ul>
<ul>Updates startSec</ul>
<ul>Resets cntSent</ul>
</li>

@param nowInMsRoundedAtSec Now in millis rounded as second
328143
private synchronized void checkNextSecond(double nowInMsRoundedAtSec) {
        // next second
        if (time == nowInMsRoundedAtSec) {
            return;
        }

        if (startSec == 0) {
            startSec = nowInMsRoundedAtSec;
        }
        time = nowInMsRoundedAtSec;

        Pair<Double, Long> pair = getRPSForSecond((nowInMsRoundedAtSec - startSec) / 1000);
        double nextRps = pair.getLeft();
        if (nextRps < 0) {
            stopping = true;
            int factor = stopTries > 10 ? 2 : 1;
            rps = rps > 0 ? rps * factor : 1;
            stopTest();
            notifyAll();
        } else {
            rps = nextRps;
        }

        if (log.isDebugEnabled()) {
            log.debug("Second changed {} , waiting: {}, samples sent {}, current rps: {} rps",
                    ((nowInMsRoundedAtSec - startSec) / 1000), cntDelayed, cntSent, rps);
        }

        if (cntDelayed < 1 && cntSent < rps) {
            log.warn("No free threads available in current Thread Group {}, made {} samples/s for expected rps {} samples/s, increase your number of threads",
                    JMeterContextService.getContext().getThreadGroup().getName(), cntSent, rps);
        }

        String elementName = getName();
        JMeterUtils.setProperty(elementName + "_totalDuration", String.valueOf(pair.getRight()));
        JMeterUtils.setProperty(elementName + "_cntDelayed", String.valueOf(cntDelayed));
        JMeterUtils.setProperty(elementName + "_cntSent", String.valueOf(cntSent));
        JMeterUtils.setProperty(elementName + "_rps", String.valueOf(rps));

        cntSent = 0;
        msecPerReq = 1000d / rps;
    }
685082
private void updateAperture(int newValue, long now) {
    int previous = targetAperture;
    targetAperture = newValue;
    targetAperture = Math.max(minAperture, targetAperture);
    int maxAperture = Math.min(this.maxAperture, activeSockets.size() + pool.poolSize());
    targetAperture = Math.min(maxAperture, targetAperture);
    lastApertureRefresh = now;
    pendings.reset((minPendings + maxPendings) / 2);

    if (targetAperture != previous) {
      logger.debug(
          "Current pending={}, new target={}, previous target={}",
          pendings.value(),
          targetAperture,
          previous);
    }
  }
1322152
public void setLastAccessTime(long lastAccessTime) {
    while (true) {
      long current = this.lastAccessTime;
      if (current >= lastAccessTime) {
        break;
      }
      if (ACCESSTIME_UPDATER.compareAndSet(this, current, lastAccessTime)) {
        break;
      }
    }
  }
1031483
private void finishKbMode(boolean updateDisplays) {
        mInKbMode = false;
        if (!mTypedTimes.isEmpty()) {
            int values[] = getEnteredTime(null);
            mTimePicker.setTime(values[0], values[1]);
            if (!mIs24HourMode) {
                mTimePicker.setAmOrPm(values[2]);
            }
            mTypedTimes.clear();
        }
        if (updateDisplays) {
            updateDisplay(false);
            mTimePicker.trySettingInputEnabled(true);
        }
    }
311346
protected void markTime(final StringBuilder b, long t1, long t2) {
        boolean time = getPhaseConfiguration().isTime();
        if (time) {
            String seconds = timeFormat((t2 - t1));
            b.append("(");
            b.append(seconds);
            b.append(" seconds) ");
        }
    }
30932
@Override
    public void onValueSelected(Timepoint newValue) {
        setHour(newValue.getHour(), false);
        mTimePicker.setContentDescription(mHourPickerDescription + ": " + newValue.getHour());
        setMinute(newValue.getMinute());
        mTimePicker.setContentDescription(mMinutePickerDescription + ": " + newValue.getMinute());
        setSecond(newValue.getSecond());
        mTimePicker.setContentDescription(mSecondPickerDescription + ": " + newValue.getSecond());
        if(!mIs24HourMode) updateAmPmDisplay(newValue.isAM() ? AM : PM);
    }
170148
function getHrTimeDurationInMs (startTime, endTime) {
    if (startTime === null || endTime === null) {
        return null;
    }

    var secondDiff = endTime[0] - startTime[0];
    var nanoSecondDiff = endTime[1] - startTime[1];
    var diffInNanoSecond = secondDiff * NS_PER_SEC + nanoSecondDiff;

    return Math.round(diffInNanoSecond / MS_PER_NS);
}
207570
private void elapsedTime(long startTime)
    {
        /** time elapsed in nanoseconds */
        long eta = System.nanoTime() - startTime;

        sessionState.out.print("Elapsed time: ");
        if (eta < 10000000)
        {
            sessionState.out.print(Math.round(eta/10000.0)/100.0);
        }
        else
        {
            sessionState.out.print(Math.round(eta/1000000.0));
        }
        sessionState.out.println(" msec(s).");
    }
116036
public void processNack(ControlNack nm)
    throws SIResourceException
  {
    if (tc.isEntryEnabled())
          SibTr.entry(tc, "processNack", nm);
 
    long startstamp = nm.getStartTick();
    long endstamp = nm.getEndTick();

    synchronized (this)
    {
      // the following steps are performed:
      // (1) check ticks in Unknown
      // (2) create nacks when appropriate
      // (3) change Unknown ticks to Requested
      // (4) send nacks.

      iststream.setCursor(startstamp);
      boolean changed = false;
      TickRange tr = iststream.getNext();
      TickRange tr2;

      do
      {
        // look at each TickRange individually
        // and send nacks for ranges that are not already in Requested state
        if (tr.type == TickRange.Unknown)
        {
          changed = true;
          long maxStartstamp = max(tr.startstamp, startstamp);
          long minEndstamp = min(tr.endstamp, endstamp);
        
          upControl.sendNackMessage(null, null, null, maxStartstamp, minEndstamp, priority, reliability, streamID);
        }

        tr2 = tr;
        tr = iststream.getNext();
      }
      while ((tr.startstamp <= endstamp) && (tr2 != tr));

      if (changed)
      {
        // update the stream to Requested
        tr = new TickRange(TickRange.Requested, startstamp, endstamp);
        iststream.writeRange(tr);

        // start a timer to forget this Request 
        new ReqExpiryHandle(tr);
      }

    } // end synchronized (this)
   
    if (tc.isEntryEnabled())
      SibTr.exit(tc, "processNack");
  }
1087479
@SuppressWarnings("NarrowingCompoundAssignment")
  private static long normalizedDuration(long seconds, int nanos) {
    if (nanos <= -NANOS_PER_SECOND || nanos >= NANOS_PER_SECOND) {
      seconds = checkedAdd(seconds, nanos / NANOS_PER_SECOND);
      nanos %= NANOS_PER_SECOND;
    }
    if (seconds > 0 && nanos < 0) {
      nanos += NANOS_PER_SECOND; // no overflow since nanos is negative (and we're adding)
      seconds--; // no overflow since seconds is positive (and we're decrementing)
    }
    if (seconds < 0 && nanos > 0) {
      nanos -= NANOS_PER_SECOND; // no overflow since nanos is positive (and we're subtracting)
      seconds++; // no overflow since seconds is negative (and we're incrementing)
    }
    if (!durationIsValid(seconds, nanos)) {
      throw new IllegalArgumentException(String.format(
          "Duration is not valid. See proto definition for valid values. "
              + "Seconds (%s) must be in range [-315,576,000,000, +315,576,000,000]. "
              + "Nanos (%s) must be in range [-999,999,999, +999,999,999]. "
              + "Nanos must have the same sign as seconds", seconds, nanos));
    }
    return saturatedAdd(TimeUnit.SECONDS.toNanos(seconds), nanos);
  }
1012640
public long nextKey() {
        // Note that per Oracle the currentTimeMillis is the current number of seconds past the epoch
        // in UTC (not in local time). Therefore, processes with exactly synchronized clocks will
        // always get the same value regardless of their timezone ...
        final long timestamp = System.currentTimeMillis();
        final int increment = counterFor(timestamp);
        if (increment <= maximumCounterValue) {
            return (timestamp << counterBits) + increment;
        }
        // The counter is surprisingly too high, so try again (repeatedly) until we get to the next millisecond ...
        return this.nextKey();
    }
453639
private Timepoint roundToValidTime(Timepoint newSelection, int currentItemShowing) {
        switch(currentItemShowing) {
            case HOUR_INDEX:
                return mController.roundToNearest(newSelection, null);
            case MINUTE_INDEX:
                return mController.roundToNearest(newSelection, Timepoint.TYPE.HOUR);
            default:
                return mController.roundToNearest(newSelection, Timepoint.TYPE.MINUTE);
        }
    }
1229914
public synchronized void onRequestSucceeded(long startTimeInNanos) {
		long micros = (System.nanoTime() - startTimeInNanos) / 1000;
		allRequestsTracker.onRequestSucceeded(micros);
		recentRequestsTracker.onRequestSucceeded(micros);
		meter.mark();
	}
376768
@Override
  public void setStartTime(final long timestamp) {
    if (timestamp < 0 || ((timestamp & Const.SECOND_MASK) != 0 && 
        timestamp > 9999999999999L)) {
      throw new IllegalArgumentException("Invalid timestamp: " + timestamp);
    } else if (end_time != UNSET && timestamp >= getEndTime()) {
      throw new IllegalArgumentException("new start time (" + timestamp
          + ") is greater than or equal to end time: " + getEndTime());
    }
    start_time = timestamp;
  }
1367396
public Instant getNextExecutionTimeAfter(Instant now) {
        OffsetTime timeOfDay = OffsetTime.from(TIME_OF_DAY_FORMAT.parse(getTimeOfDay()));

        // The time of the next run is based on the time past midnight UTC relative to the current time
        Instant nextExecTime = now.atOffset(ZoneOffset.UTC).with(timeOfDay).toInstant();

        // If the first execution would have been for earlier today move to the next execution.
        while (nextExecTime.isBefore(now)) {
            nextExecTime = nextExecTime.plus(Duration.ofDays(1));
        }

        return nextExecTime;
    }
1219728
public static long waitTillNextMillisec(long currentMillisec) {
        long nextMillisec = System.currentTimeMillis();
        for (; nextMillisec <= currentMillisec; nextMillisec = System.currentTimeMillis()) {
            Thread.yield();
        }
        return nextMillisec;
    }
224942
@Override
    public Future<Long> ping(final Long timestamp) {
        try {
            validateMiddleware();
        } catch (InvalidStateException e) {
            try {
                waitForMiddleware(1, TimeUnit.SECONDS);
            } catch (InterruptedException ex) {
                Thread.currentThread().interrupt();
                FutureProcessor.canceledFuture(ex);
            } catch (CouldNotPerformException ex) {
                // controller not ready to respond.
                FutureProcessor.canceledFuture(ex);
            }
        }
        return FutureProcessor.completedFuture(timestamp);
    }