<commit_before>package main

import (
	"github.com/nsqio/go-nsq"
	"github.com/raintank/met/helper"
	"github.com/raintank/raintank-metric/metricdef"
	"github.com/raintank/raintank-metric/msg"
	"github.com/raintank/raintank-metric/schema"
	"testing"
)

func BenchmarkHandler_HandleMessage1000(b *testing.B) {
	stats, _ := helper.New(false, "", "standard", "metrics_tank", "")
	clusterStatus = NewClusterStatus("default", false)
	initMetrics(stats)

	store := NewDevnullStore()
	aggmetrics := NewAggMetrics(store, 600, 10, 800, 8000, 10000, make([]aggSetting, 0))
	defCache := NewDefCache(metricdef.NewDefsMock())
	handler := NewHandler(aggmetrics, defCache)

	metric := &schema.MetricData{
		Id:         "some.id.of.a.metric",
		OrgId:      500,
		Name:       "some.id",
		Metric:     "metric",
		Interval:   60,
		Value:      1234.567,
		Unit:       "ms",
		Time:       1234567890,
		TargetType: "gauge",
		Tags:       []string{"some_tag", "ok"},
	}

	metrics := make([]*schema.MetricData, 0)
	for i := 0; i < 10; i++ {
		metrics = append(metrics, metric)
	}
	id := nsq.MessageID{'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 's', 'd', 'f', 'g', 'h'}
	data, err := msg.CreateMsg(metrics, 1, msg.FormatMetricDataArrayMsgp)
	if err != nil {
		panic(err)
	}
	nsqmsg := nsq.NewMessage(id, data)

	b.StartTimer()
	for n := 0; n < b.N; n++ {
		for i := 0; i < 1000; i++ {
			err := handler.HandleMessage(nsqmsg)
			if err != nil {
				panic(err)
			}
		}
	}
}<commit_msg>increment test metrics timestamps properly<commit_after>package main

import (
	"github.com/nsqio/go-nsq"
	"github.com/raintank/met/helper"
	"github.com/raintank/raintank-metric/metricdef"
	"github.com/raintank/raintank-metric/msg"
	"github.com/raintank/raintank-metric/schema"
	"testing"
)

func BenchmarkHandler_HandleMessage1000(b *testing.B) {
	stats, _ := helper.New(false, "", "standard", "metrics_tank", "")
	clusterStatus = NewClusterStatus("default", false)
	initMetrics(stats)

	store := NewDevnullStore()
	aggmetrics := NewAggMetrics(store, 600, 10, 800, 8000, 10000, make([]aggSetting, 0))
	defCache := NewDefCache(metricdef.NewDefsMock())
	handler := NewHandler(aggmetrics, defCache)

	metrics := make([]*schema.MetricData, 10)
	for i := 0; i < len(metrics); i++ {
		metrics[i] = &schema.MetricData{
			Id:         "some.id.of.a.metric",
			OrgId:      500,
			Name:       "some.id",
			Metric:     "metric",
			Interval:   60,
			Value:      1234.567,
			Unit:       "ms",
			Time:       1234567890 + int64(i),
			TargetType: "gauge",
			Tags:       []string{"some_tag", "ok"},
		}
	}
	msgs := make([]*nsq.Message, 1000)
	for i := 0; i < len(msgs); i++ {
		id := nsq.MessageID{'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 's', 'd', 'f', 'g', 'h'}
		for j := 0; j < len(metrics); j++ {
			metrics[j].Time += 10
		}
		data, err := msg.CreateMsg(metrics, 1, msg.FormatMetricDataArrayMsgp)
		if err != nil {
			panic(err)
		}
		msgs[i] = nsq.NewMessage(id, data)
	}

	b.StartTimer()
	for n := 0; n < b.N; n++ {
		for i := 0; i < len(msgs); i++ {
			err := handler.HandleMessage(msgs[i])
			if err != nil {
				panic(err)
			}
		}
	}
}
{'fraction_non_alphanumeric': 0.19411576590981772, 'fraction_numerical': 0.04317236968340262, 'mean_word_length': 3.500719424460432, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4901708', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1215, 'n_words': 257}