// Copyright (C) 2018 rameshvk. All rights reserved.
// Use of this source code is governed by a MIT-style license
// that can be found in the LICENSE file.

package dot_test

import (
	"testing"

	"github.com/dotchain/dot/changes"
	"github.com/dotchain/dot/changes/types"
)

func BenchmarkMergeNonConflicting(b *testing.B) {
	left, right := changes.ChangeSet{}, changes.ChangeSet{}
	count := 1500

	for kk := 0; kk < count; kk++ {
		c := changes.Splice{Offset: kk, Before: types.S8(" "), After: types.S8("")}
		left = append(left, c)
		c.Offset += count
		right = append(right, c)
	}

	changes.Merge(left, right)
}

func BenchmarkMergeConflicting(b *testing.B) {
	left, right := changes.ChangeSet{}, changes.ChangeSet{}
	count := 1500

	for kk := 0; kk < count; kk++ {
		c := changes.Splice{Offset: kk, Before: types.S8(" "), After: types.S8("")}
		left = append(left, c)

		c.Before, c.After = c.After, c.Before
		right = append(right, c)
	}

	changes.Merge(left, right)
}

Related articles

dot config

// Copyright (C) 2018 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package sync import ( "time" "github.com/dotchain/dot/log" "github.com/dotchain/dot/ops" )

dot empty

// Copyright (C) 2018 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package changes // Nil represents an empty value. It can be used with Replace or // Splice to i

dot caret_test

// Copyright (C) 2018 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package refs_test import ( "reflect" "testing" "github.com/dotchain/dot/changes" "github.c

dot nw_test

// Copyright (C) 2018 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package nw_test import ( "bytes" "context" "errors" "net/http" "net/http/httptest" "testi

dot image

// Copyright (C) 2019 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package data import ( "github.com/dotchain/dot/changes" "github.com/dotchain/dot/changes/type

dot rank_test

// Copyright (C) 2019 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package crdt_test import ( "testing" "github.com/dotchain/dot/changes/crdt" ) func TestNewR

dot ord_test

// Copyright (C) 2019 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package crdt_test import ( "testing" "github.com/dotchain/dot/changes/crdt" ) func TestIntN

dot generated2

// Generated. DO NOT EDIT. package mystruct import ( "github.com/dotchain/dot/changes" "github.com/dotchain/dot/changes/types" "github.com/dotchain/dot/streams" ) func (my *myStructp) get(key interface{}) changes.Value { switch key { case "b":

dot todo

// Code generated by github.com/tvastar/test/cmd/testmd/testmd.go. DO NOT EDIT. package example import ( "net/http" "sync" "time" "github.com/dotchain/dot" "github.com/dotchain/dot/ops/nw" ) func Server() { // import net/http // import github.

dot callable_test

// Copyright (C) 2019 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package eval_test import ( "testing" "github.com/dotchain/dot/changes" "github.com/dotchain