<commit_before>// Copyright 2014 The lime Authors.
// Use of this source code is governed by a 2-clause
// BSD-style license that can be found in the LICENSE file.

package util

import (
	"testing"
	"time"
)

func TestSortByName(t *testing.T) {
	Prof.data["A"] = ProfileEntry{Calls: 1, Tottime: time.Duration(5)}
	Prof.data["B"] = ProfileEntry{Calls: 1, Tottime: time.Duration(4)}
	Prof.data["C"] = ProfileEntry{Calls: 1, Tottime: time.Duration(3)}
	Prof.data["D"] = ProfileEntry{Calls: 1, Tottime: time.Duration(2)}		
	results := Prof.SortByName()
	if results[0].Name != "A" {
		t.Error("TestSortByName expected A, but got %s", results[0].Name)
	}
	if results[1].Name != "B" {
		t.Error("TestSortByName expected B, but got %s", results[1].Name)
	}
	if results[2].Name != "C" {
		t.Error("TestSortByName expected C, but got %s", results[2].Name)
	}
	if results[3].Name != "D" {
		t.Error("TestSortByName expected D, but got %s", results[3].Name)
	}
}

func TestSortByTime(t *testing.T) {
	Prof.data["A"] = ProfileEntry{Calls: 1, Tottime: time.Duration(1)}
	Prof.data["C"] = ProfileEntry{Calls: 1, Tottime: time.Duration(2)}
	Prof.data["D"] = ProfileEntry{Calls: 1, Tottime: time.Duration(3)}
	Prof.data["B"] = ProfileEntry{Calls: 1, Tottime: time.Duration(4)}		
	results := Prof.SortByTotalTime()
	if results[0].Name != "A" {
		t.Error("TestSortByTime expected A, but got %s", results[0].Name)
	}
	if results[1].Name != "C" {
		t.Error("TestSortByTime expected C, but got %s", results[1].Name)
	}
	if results[2].Name != "D" {
		t.Error("TestSortByTime expected D, but got %s", results[2].Name)
	}
	if results[3].Name != "B" {
		t.Error("TestSortByTime expected B, but got %s", results[3].Name)
	}
}

func TestSortByAvgTime(t *testing.T) {
	Prof.data["A"] = ProfileEntry{Calls: 1, Tottime: time.Duration(1)}
	Prof.data["C"] = ProfileEntry{Calls: 1, Tottime: time.Duration(2)}
	Prof.data["D"] = ProfileEntry{Calls: 1, Tottime: time.Duration(3)}
	Prof.data["B"] = ProfileEntry{Calls: 1, Tottime: time.Duration(4)}		
	results := Prof.SortByAvgTime()
	if results[0].Name != "A" {
		t.Error("TestSortByTime expected A, but got %s", results[0].Name)
	}
	if results[1].Name != "C" {
		t.Error("TestSortByTime expected C, but got %s", results[1].Name)
	}
	if results[2].Name != "D" {
		t.Error("TestSortByTime expected D, but got %s", results[2].Name)
	}
	if results[3].Name != "B" {
		t.Error("TestSortByTime expected B, but got %s", results[3].Name)
	}
}

func TestEnter(t *testing.T) {
	profiler := &Profiler{}
	pt := profiler.Enter("some name")

	if &pt == nil {<commit_msg>Run `gofmt` on util tests<commit_after>// Copyright 2014 The lime Authors.
// Use of this source code is governed by a 2-clause
// BSD-style license that can be found in the LICENSE file.

package util

import (
	"testing"
	"time"
)

func TestSortByName(t *testing.T) {
	Prof.data["A"] = ProfileEntry{Calls: 1, Tottime: time.Duration(5)}
	Prof.data["B"] = ProfileEntry{Calls: 1, Tottime: time.Duration(4)}
	Prof.data["C"] = ProfileEntry{Calls: 1, Tottime: time.Duration(3)}
	Prof.data["D"] = ProfileEntry{Calls: 1, Tottime: time.Duration(2)}
	results := Prof.SortByName()
	if results[0].Name != "A" {
		t.Error("TestSortByName expected A, but got %s", results[0].Name)
	}
	if results[1].Name != "B" {
		t.Error("TestSortByName expected B, but got %s", results[1].Name)
	}
	if results[2].Name != "C" {
		t.Error("TestSortByName expected C, but got %s", results[2].Name)
	}
	if results[3].Name != "D" {
		t.Error("TestSortByName expected D, but got %s", results[3].Name)
	}
}

func TestSortByTime(t *testing.T) {
	Prof.data["A"] = ProfileEntry{Calls: 1, Tottime: time.Duration(1)}
	Prof.data["C"] = ProfileEntry{Calls: 1, Tottime: time.Duration(2)}
	Prof.data["D"] = ProfileEntry{Calls: 1, Tottime: time.Duration(3)}
	Prof.data["B"] = ProfileEntry{Calls: 1, Tottime: time.Duration(4)}
	results := Prof.SortByTotalTime()
	if results[0].Name != "A" {
		t.Error("TestSortByTime expected A, but got %s", results[0].Name)
	}
	if results[1].Name != "C" {
		t.Error("TestSortByTime expected C, but got %s", results[1].Name)
	}
	if results[2].Name != "D" {
		t.Error("TestSortByTime expected D, but got %s", results[2].Name)
	}
	if results[3].Name != "B" {
		t.Error("TestSortByTime expected B, but got %s", results[3].Name)
	}
}

func TestSortByAvgTime(t *testing.T) {
	Prof.data["A"] = ProfileEntry{Calls: 1, Tottime: time.Duration(1)}
	Prof.data["C"] = ProfileEntry{Calls: 1, Tottime: time.Duration(2)}
	Prof.data["D"] = ProfileEntry{Calls: 1, Tottime: time.Duration(3)}
	Prof.data["B"] = ProfileEntry{Calls: 1, Tottime: time.Duration(4)}
	results := Prof.SortByAvgTime()
	if results[0].Name != "A" {
		t.Error("TestSortByTime expected A, but got %s", results[0].Name)
	}
	if results[1].Name != "C" {
		t.Error("TestSortByTime expected C, but got %s", results[1].Name)
	}
	if results[2].Name != "D" {
		t.Error("TestSortByTime expected D, but got %s", results[2].Name)
	}
	if results[3].Name != "B" {
		t.Error("TestSortByTime expected B, but got %s", results[3].Name)
	}
}

func TestEnter(t *testing.T) {
	profiler := &Profiler{}
	pt := profiler.Enter("some name")

	if &pt == nil {
{'fraction_non_alphanumeric': 0.18732996502137583, 'fraction_numerical': 0.020598523124757094, 'mean_word_length': 4.588490770901195, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6859426', 'n_tokens_mistral': 2059, 'n_tokens_neox': 2009, 'n_words': 478}