Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ func main() {
if startTimestamp != 0 {
startTime = time.Unix(0, startTimestamp)
} else {
startTime = time.Now()
startTime = time.Now().UTC()
}

fmt.Println("Configuration")
Expand Down
4 changes: 2 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ func TestMixedModeWithWorkloads(t *testing.T) {
partitionCount = 10
clusteringRowCount = 5
maximumRate = 1000 // Set a non-zero rate for timeseries workload
startTime = time.Now()
startTime = time.Now().UTC()

workloads := []string{"sequential", "uniform", "timeseries"}

Expand Down Expand Up @@ -654,7 +654,7 @@ func TestTimeseriesWorkloadWithMixedMode(t *testing.T) {
partitionCount = 10
clusteringRowCount = 5
maximumRate = 1000
startTime = time.Now()
startTime = time.Now().UTC()

// Test that timeseries workload with mixed mode does not panic
defer func() {
Expand Down
48 changes: 24 additions & 24 deletions modes.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type MaximumRateLimiter struct {
func (mxrl *MaximumRateLimiter) Wait() {
mxrl.CompletedOperations++
nextRequest := mxrl.StartTime.Add(mxrl.Period * time.Duration(mxrl.CompletedOperations))
now := time.Now()
now := time.Now().UTC()
if now.Before(nextRequest) {
time.Sleep(nextRequest.Sub(now))
}
Expand All @@ -67,7 +67,7 @@ func NewRateLimiter(maximumRate int, _ time.Duration) RateLimiter {
period := time.Duration(int64(time.Second) / int64(maximumRate))
return &MaximumRateLimiter{
Period: period,
StartTime: time.Now(),
StartTime: time.Now().UTC(),
CompletedOperations: 0,
}
}
Expand Down Expand Up @@ -161,7 +161,7 @@ func RunTest(
rateLimiter RateLimiter,
test func(rb *results.TestThreadResult) (time.Duration, error),
) {
start := time.Now()
start := time.Now().UTC()
partialStart := start
iter := NewTestIterator(workload)
errorsAtRow := 0
Expand All @@ -170,11 +170,11 @@ func RunTest(

expectedStartTime := rateLimiter.Expected()
if expectedStartTime.IsZero() {
expectedStartTime = time.Now()
expectedStartTime = time.Now().UTC()
}

rawLatency, err := test(threadResult)
endTime := time.Now()
endTime := time.Now().UTC()
switch {
case err == nil:
errorsAtRow = 0
Expand All @@ -194,7 +194,7 @@ func RunTest(
}
}

now := time.Now()
now := time.Now().UTC()
if maxErrorsAtRow > 0 && errorsAtRow >= maxErrorsAtRow {
threadResult.SubmitCriticalError(fmt.Errorf(
"error limit (maxErrorsAtRow) of %d errors is reached", errorsAtRow))
Expand All @@ -216,7 +216,7 @@ func RunTest(
partialStart = partialStart.Add(reportInterval)
}
}
end := time.Now()
end := time.Now().UTC()

threadResult.FullResult.ElapsedTime = end.Sub(start)
threadResult.ResultChannel <- *threadResult.FullResult
Expand Down Expand Up @@ -417,9 +417,9 @@ func createWriteTestFunc(session *gocql.Session, workload workloads.Generator, v
queryStr := ""
currentAttempts := 0
for {
requestStart := time.Now()
requestStart := time.Now().UTC()
err = bound.Exec()
requestEnd := time.Now()
requestEnd := time.Now().UTC()

if err == nil {
rb.IncOps()
Expand Down Expand Up @@ -517,9 +517,9 @@ func DoBatchedWrites(
queryStr := ""
currentAttempts := 0
for {
requestStart := time.Now()
requestStart := time.Now().UTC()
err := session.ExecuteBatch(batch)
requestEnd := time.Now()
requestEnd := time.Now().UTC()

if err == nil {
rb.IncOps()
Expand Down Expand Up @@ -572,9 +572,9 @@ func DoCounterUpdates(
queryStr := ""
currentAttempts := 0
for {
requestStart := time.Now()
requestStart := time.Now().UTC()
err := query.Exec()
requestEnd := time.Now()
requestEnd := time.Now().UTC()

if err == nil {
rb.IncOps()
Expand Down Expand Up @@ -760,9 +760,9 @@ func createReadTestFunc(table string, session *gocql.Session, workload workloads
queryStr := query.String()

for currentAttempts := 0; ; currentAttempts++ {
requestStart := time.Now()
requestStart := time.Now().UTC()
err := executeReadsQuery(query, table, rb, validateData)
requestEnd := time.Now()
requestEnd := time.Now().UTC()

if err == nil {
rb.IncOps()
Expand Down Expand Up @@ -802,13 +802,13 @@ func DoScanTable(session *gocql.Session, threadResult *results.TestThreadResult,
queryStr := query.String()

for currentAttempts := 0; ; currentAttempts++ {
requestStart := time.Now()
requestStart := time.Now().UTC()
query.Bind(currentRange.Start, currentRange.End)
iter := query.Iter()
for iter.Scan(nil, nil, nil) {
rb.IncRows()
}
requestEnd := time.Now()
requestEnd := time.Now().UTC()
err := iter.Close()

if err == nil {
Expand Down Expand Up @@ -842,7 +842,7 @@ func DoMixed(

expectedStartTime := rateLimiter.Expected()
if expectedStartTime.IsZero() {
expectedStartTime = time.Now()
expectedStartTime = time.Now().UTC()
}

// Perform write on even operations, read on odd operations
Expand All @@ -852,7 +852,7 @@ func DoMixed(
rawLatency, err := writeTestFunc(rb)
if err == nil {
// Record coordinated omission fixed latency for write operations
endTime := time.Now()
endTime := time.Now().UTC()
rb.RecordWriteCoFixedLatency(endTime.Sub(expectedStartTime))
}
return rawLatency, err
Expand All @@ -861,7 +861,7 @@ func DoMixed(
rawLatency, err := readTestFunc(rb)
if err == nil {
// Record coordinated omission fixed latency for read operations
endTime := time.Now()
endTime := time.Now().UTC()
rb.RecordReadCoFixedLatency(endTime.Sub(expectedStartTime))
}
return rawLatency, err
Expand Down Expand Up @@ -889,9 +889,9 @@ func createMixedWriteTestFunc(session *gocql.Session, workload workloads.Generat
queryStr := ""
currentAttempts := 0
for {
requestStart := time.Now()
requestStart := time.Now().UTC()
err = bound.Exec()
requestEnd := time.Now()
requestEnd := time.Now().UTC()

if err == nil {
rb.IncOps()
Expand Down Expand Up @@ -956,7 +956,7 @@ func createMixedReadTestFunc(table string, session *gocql.Session, workload work
queryStr := ""
currentAttempts := 0
for {
requestStart := time.Now()
requestStart := time.Now().UTC()
iter := query.Iter()

var (
Expand Down Expand Up @@ -985,7 +985,7 @@ func createMixedReadTestFunc(table string, session *gocql.Session, workload work
}
}

requestEnd := time.Now()
requestEnd := time.Now().UTC()
err := iter.Close()
if err == nil {
rb.IncOps()
Expand Down
6 changes: 3 additions & 3 deletions modes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,15 @@ func TestMixedModeCoFixedLatencyRecording(t *testing.T) {

// Mock rate limiter that returns a known expected time
mockRateLimiter := &MaximumRateLimiter{
StartTime: time.Now().Add(-time.Second), // 1 second ago
Period: time.Millisecond * 10, // 10ms between operations
StartTime: time.Now().UTC().Add(-time.Second), // 1 second ago
Period: time.Millisecond * 10, // 10ms between operations
}

// Test that the DoMixed function structure correctly handles expectedStartTime
// by checking that rateLimiter.Expected() is called within the test function

// Create a test that verifies the logic without database operations
testStartTime := time.Now()
testStartTime := time.Now().UTC()
expectedStartTime := mockRateLimiter.Expected()
if expectedStartTime.IsZero() {
expectedStartTime = testStartTime
Expand Down
4 changes: 2 additions & 2 deletions pkg/results/merged_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type MergedResult struct {
func NewMergedResult() *MergedResult {
result := &MergedResult{}
if globalResultConfiguration.measureLatency {
result.HistogramStartTime = time.Now().UnixNano()
result.HistogramStartTime = time.Now().UTC().UnixNano()
result.RawLatency = NewHistogram(
&globalResultConfiguration.latencyHistogramConfiguration,
"raw",
Expand Down Expand Up @@ -165,7 +165,7 @@ func (mr *MergedResult) getLatencyHistogram() *hdrhistogram.Histogram {

func (mr *MergedResult) SaveLatenciesToHdrHistogram(hdrLogWriter *hdrhistogram.HistogramLogWriter) {
startTimeMs := mr.HistogramStartTime / 1000000
endTimeMs := time.Now().UnixNano() / 1000000
endTimeMs := time.Now().UTC().UnixNano() / 1000000

// Save standard histograms
mr.CoFixedLatency.SetStartTimeMs(startTimeMs)
Expand Down
2 changes: 1 addition & 1 deletion pkg/results/thread_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (r *TestThreadResult) RecordWriteCoFixedLatency(latency time.Duration) {
}

func (r *TestThreadResult) SubmitResult() {
now := time.Now()
now := time.Now().UTC()
if now.Sub(r.partialStart) > time.Second {
r.ResultChannel <- *r.PartialResult
r.ResetPartialResult()
Expand Down
4 changes: 2 additions & 2 deletions pkg/results/thread_results.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (tr *TestResults) Init(concurrency int) {
}

func (tr *TestResults) SetStartTime() {
tr.startTime = time.Now()
tr.startTime = time.Now().UTC()
}

func (tr *TestResults) GetTestResult(idx int) *TestThreadResult {
Expand Down Expand Up @@ -72,7 +72,7 @@ func (tr *TestResults) GetTotalResults() {
// before reducing it from start time, which is divided by 1000000000 before applied to histogram
// giving small chance that rounded baseTime would be greater than histogram start time and negative
// times in the histogram log
baseTime := (time.Now().UnixNano() / 1000000000) * 1000000000
baseTime := (time.Now().UTC().UnixNano() / 1000000000) * 1000000000

var hdrLogWriter *hdrhistogram.HistogramLogWriter
if globalResultConfiguration.hdrLatencyFile != "" {
Expand Down
8 changes: 4 additions & 4 deletions pkg/workloads/workloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func NewRandomUniform(
i int,
partitionCount, partitionOffset, clusteringRowCount int64,
) *RandomUniform {
generator := rand.New(rand.NewSource(int64(time.Now().Nanosecond() * (i + 1))))
generator := rand.New(rand.NewSource(int64(time.Now().UTC().Nanosecond() * (i + 1))))
return &RandomUniform{
generator,
int64(partitionCount),
Expand Down Expand Up @@ -233,7 +233,7 @@ func NewTimeSeriesReader(
default:
log.Fatal("unknown distribution", distribution)
}
generator := rand.New(rand.NewSource(int64(time.Now().Nanosecond() * (threadID + 1))))
generator := rand.New(rand.NewSource(int64(time.Now().UTC().Nanosecond() * (threadID + 1))))
pkStride := int64(threadCount)
pkOffset := (int64(threadID) % pkCount) + basicPkOffset
period := time.Second.Nanoseconds() / writeRate
Expand Down Expand Up @@ -261,13 +261,13 @@ func (tsw *TimeSeriesRead) NextPartitionKey() int64 {
if tsw.PkPosition >= tsw.PkCount+tsw.PkOffset {
tsw.PkPosition = tsw.PkOffset
}
maxGeneration := (time.Now().UnixNano()-tsw.StartTimestamp)/(tsw.Period*tsw.CkCount) + 1
maxGeneration := (time.Now().UTC().UnixNano()-tsw.StartTimestamp)/(tsw.Period*tsw.CkCount) + 1
tsw.CurrentGeneration = RandomInt64(tsw.Generator, tsw.HalfNormalDist, maxGeneration)
return tsw.PkPosition<<32 | tsw.CurrentGeneration
}

func (tsw *TimeSeriesRead) NextClusteringKey() int64 {
maxRange := (time.Now().UnixNano()-tsw.StartTimestamp)/tsw.Period - tsw.CurrentGeneration*tsw.CkCount + 1
maxRange := (time.Now().UTC().UnixNano()-tsw.StartTimestamp)/tsw.Period - tsw.CurrentGeneration*tsw.CkCount + 1
maxRange = min(tsw.CkCount, maxRange)
timestampDelta := (tsw.CurrentGeneration*tsw.CkCount + RandomInt64(tsw.Generator, tsw.HalfNormalDist, maxRange)) * tsw.Period
return -(timestampDelta + tsw.StartTimestamp)
Expand Down
4 changes: 2 additions & 2 deletions pkg/workloads/workloads_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestSequentialWorkload(t *testing.T) {
generator := rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
generator := rand.New(rand.NewSource(int64(time.Now().UTC().Nanosecond())))
testCases := []struct {
rowOffset int64
rowCount int64
Expand Down Expand Up @@ -84,7 +84,7 @@ func TestSequentialWorkload(t *testing.T) {
}

func TestUniformWorkload(t *testing.T) {
generator := rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
generator := rand.New(rand.NewSource(int64(time.Now().UTC().Nanosecond())))
testCases := []struct {
partitionCount int64
partitionOffset int64
Expand Down
2 changes: 1 addition & 1 deletion random/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
)

var (
globalSeed = uint64(time.Now().UnixNano() + int64(os.Getpid()))
globalSeed = uint64(time.Now().UTC().UnixNano() + int64(os.Getpid()))
// globalRand is a copy of the rand.globalRand (git.io/fA2Ls) for
// user mode package's use only.
globalRand = NewLockedRandom(globalSeed)
Expand Down
Loading