ROOTPLOIT
Server: LiteSpeed
System: Linux in-mum-web1878.main-hosting.eu 5.14.0-570.21.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 11 07:22:35 EDT 2025 x86_64
User: u435929562 (435929562)
PHP: 7.4.33
Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/golang/1.22.0/src/cmd/compile/internal/test/testdata/pgo/devirtualize/devirt_test.go
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// WARNING: Please avoid updating this file. If this file needs to be updated,
// then a new devirt.pprof file should be generated:
//
//	$ cd $GOROOT/src/cmd/compile/internal/test/testdata/pgo/devirtualize/
//	$ go mod init example.com/pgo/devirtualize
//	$ go test -bench=. -cpuprofile ./devirt.pprof

package devirt

import (
	"testing"

	"example.com/pgo/devirtualize/mult.pkg"
)

func BenchmarkDevirtIface(b *testing.B) {
	var (
		a1 Add
		a2 Sub
		m1 mult.Mult
		m2 mult.NegMult
	)

	ExerciseIface(b.N, a1, a2, m1, m2)
}

// Verify that devirtualization doesn't result in calls or side effects applying more than once.
func TestDevirtIface(t *testing.T) {
	var (
		a1 Add
		a2 Sub
		m1 mult.Mult
		m2 mult.NegMult
	)

	if v := ExerciseIface(10, a1, a2, m1, m2); v != 1176 {
		t.Errorf("ExerciseIface(10) got %d want 1176", v)
	}
}

func BenchmarkDevirtFuncConcrete(b *testing.B) {
	ExerciseFuncConcrete(b.N, AddFn, SubFn, mult.MultFn, mult.NegMultFn)
}

func TestDevirtFuncConcrete(t *testing.T) {
	if v := ExerciseFuncConcrete(10, AddFn, SubFn, mult.MultFn, mult.NegMultFn); v != 1176 {
		t.Errorf("ExerciseFuncConcrete(10) got %d want 1176", v)
	}
}

func BenchmarkDevirtFuncField(b *testing.B) {
	ExerciseFuncField(b.N, AddFn, SubFn, mult.MultFn, mult.NegMultFn)
}

func TestDevirtFuncField(t *testing.T) {
	if v := ExerciseFuncField(10, AddFn, SubFn, mult.MultFn, mult.NegMultFn); v != 1176 {
		t.Errorf("ExerciseFuncField(10) got %d want 1176", v)
	}
}

func BenchmarkDevirtFuncClosure(b *testing.B) {
	ExerciseFuncClosure(b.N, AddClosure(), SubClosure(), mult.MultClosure(), mult.NegMultClosure())
}

func TestDevirtFuncClosure(t *testing.T) {
	if v := ExerciseFuncClosure(10, AddClosure(), SubClosure(), mult.MultClosure(), mult.NegMultClosure()); v != 1176 {
		t.Errorf("ExerciseFuncClosure(10) got %d want 1176", v)
	}
}