xref: /aosp_15_r20/external/licenseclassifier/internal/sets/sets_benchmark_test.go (revision 46c4c49da23cae783fa41bf46525a6505638499a)
1*46c4c49dSIbrahim Kanouche// Copyright 2017 Google Inc.
2*46c4c49dSIbrahim Kanouche//
3*46c4c49dSIbrahim Kanouche// Licensed under the Apache License, Version 2.0 (the "License");
4*46c4c49dSIbrahim Kanouche// you may not use this file except in compliance with the License.
5*46c4c49dSIbrahim Kanouche// You may obtain a copy of the License at
6*46c4c49dSIbrahim Kanouche//
7*46c4c49dSIbrahim Kanouche//	http://www.apache.org/licenses/LICENSE-2.0
8*46c4c49dSIbrahim Kanouche//
9*46c4c49dSIbrahim Kanouche// Unless required by applicable law or agreed to in writing, software
10*46c4c49dSIbrahim Kanouche// distributed under the License is distributed on an "AS IS" BASIS,
11*46c4c49dSIbrahim Kanouche// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*46c4c49dSIbrahim Kanouche// See the License for the specific language governing permissions and
13*46c4c49dSIbrahim Kanouche// limitations under the License.
14*46c4c49dSIbrahim Kanouchepackage sets
15*46c4c49dSIbrahim Kanouche
16*46c4c49dSIbrahim Kanoucheimport (
17*46c4c49dSIbrahim Kanouche	"strings"
18*46c4c49dSIbrahim Kanouche	"testing"
19*46c4c49dSIbrahim Kanouche)
20*46c4c49dSIbrahim Kanouche
21*46c4c49dSIbrahim Kanoucheconst (
22*46c4c49dSIbrahim Kanouche	postmodernThesisCollapse = `1. Expressions of collapse
23*46c4c49dSIbrahim Kanouche
24*46c4c49dSIbrahim KanoucheIf one examines postcultural Marxism, one is faced with a choice: either
25*46c4c49dSIbrahim Kanouchereject capitalist submodern theory or conclude that the purpose of the reader
26*46c4c49dSIbrahim Kanoucheis significant form. Bataille uses the termcapitalist constructionto denote
27*46c4c49dSIbrahim Kanouchenot, in fact, discourse, but prediscourse.
28*46c4c49dSIbrahim Kanouche
29*46c4c49dSIbrahim KanoucheTherefore, in Stardust, Gaiman analyses postcultural Marxism; in
30*46c4c49dSIbrahim KanoucheThe Books of Magic, although, he denies capitalist submodern theory. If
31*46c4c49dSIbrahim Kanouchecapitalist construction holds, we have to choose between capitalist submodern
32*46c4c49dSIbrahim Kanouchetheory and Baudrillardist simulacra.
33*46c4c49dSIbrahim Kanouche
34*46c4c49dSIbrahim KanoucheHowever, conceptualist socialism implies that narrativity may be used to
35*46c4c49dSIbrahim Kanoucheoppress the proletariat, given that sexuality is distinct from art. The subject
36*46c4c49dSIbrahim Kanoucheis interpolated into a capitalist construction that includes language as a
37*46c4c49dSIbrahim Kanoucheparadox.
38*46c4c49dSIbrahim Kanouche`
39*46c4c49dSIbrahim Kanouche	postmodernThesisNarratives = `1. Narratives of failure
40*46c4c49dSIbrahim Kanouche
41*46c4c49dSIbrahim KanoucheThe main theme of the works of Joyce is the defining characteristic, and some
42*46c4c49dSIbrahim Kanouchewould say the economy, of neocultural class. But Bataille promotes the use of
43*46c4c49dSIbrahim Kanouchesocialist realism to deconstruct sexual identity.
44*46c4c49dSIbrahim Kanouche
45*46c4c49dSIbrahim KanoucheThe subject is interpolated into a Baudrillardist simulation that includes
46*46c4c49dSIbrahim Kanoucheconsciousness as a whole. Thus, the primary theme of Pickett's[1] model of
47*46c4c49dSIbrahim Kanouchesocialist realism is the role of the reader as artist.
48*46c4c49dSIbrahim Kanouche
49*46c4c49dSIbrahim KanoucheThe subject is contextualised into a postcapitalist discourse that includes
50*46c4c49dSIbrahim Kanouchelanguage as a paradox. It could be said that if Baudrillardist simulation
51*46c4c49dSIbrahim Kanoucheholds, the works of Gibson are postmodern. The characteristic theme of the
52*46c4c49dSIbrahim Kanoucheworks of Gibson is the common ground between society and narrativity. However,
53*46c4c49dSIbrahim KanoucheSartre uses the term 'postcapitalist discourse' to denote not, in fact,
54*46c4c49dSIbrahim Kanouchenarrative, but postnarrative.
55*46c4c49dSIbrahim Kanouche`
56*46c4c49dSIbrahim Kanouche)
57*46c4c49dSIbrahim Kanouche
58*46c4c49dSIbrahim Kanouchevar (
59*46c4c49dSIbrahim Kanouche	// Word lists:
60*46c4c49dSIbrahim Kanouche	stringsA = strings.Fields(postmodernThesisCollapse)
61*46c4c49dSIbrahim Kanouche	stringsB = strings.Fields(postmodernThesisNarratives)
62*46c4c49dSIbrahim Kanouche)
63*46c4c49dSIbrahim Kanouche
64*46c4c49dSIbrahim Kanouchefunc BenchmarkStringSets_NewStringSet(b *testing.B) {
65*46c4c49dSIbrahim Kanouche	b.ResetTimer()
66*46c4c49dSIbrahim Kanouche	for i := 0; i < b.N; i++ {
67*46c4c49dSIbrahim Kanouche		NewStringSet(stringsA...)
68*46c4c49dSIbrahim Kanouche	}
69*46c4c49dSIbrahim Kanouche}
70*46c4c49dSIbrahim Kanouche
71*46c4c49dSIbrahim Kanouchefunc BenchmarkStringSets_Copy(b *testing.B) {
72*46c4c49dSIbrahim Kanouche	s := NewStringSet(stringsA...)
73*46c4c49dSIbrahim Kanouche
74*46c4c49dSIbrahim Kanouche	b.ResetTimer()
75*46c4c49dSIbrahim Kanouche	for i := 0; i < b.N; i++ {
76*46c4c49dSIbrahim Kanouche		s.Copy()
77*46c4c49dSIbrahim Kanouche	}
78*46c4c49dSIbrahim Kanouche}
79*46c4c49dSIbrahim Kanouche
80*46c4c49dSIbrahim Kanouchefunc BenchmarkStringSets_Insert(b *testing.B) {
81*46c4c49dSIbrahim Kanouche	b.ResetTimer()
82*46c4c49dSIbrahim Kanouche	for i := 0; i < b.N; i++ {
83*46c4c49dSIbrahim Kanouche		s := NewStringSet()
84*46c4c49dSIbrahim Kanouche		s.Insert(stringsA...)
85*46c4c49dSIbrahim Kanouche		s.Insert(stringsB...)
86*46c4c49dSIbrahim Kanouche	}
87*46c4c49dSIbrahim Kanouche}
88*46c4c49dSIbrahim Kanouche
89*46c4c49dSIbrahim Kanouchefunc BenchmarkStringSets_Delete(b *testing.B) {
90*46c4c49dSIbrahim Kanouche	b.ResetTimer()
91*46c4c49dSIbrahim Kanouche	for i := 0; i < b.N; i++ {
92*46c4c49dSIbrahim Kanouche		s := NewStringSet(stringsA...)
93*46c4c49dSIbrahim Kanouche		s.Delete(stringsB...)
94*46c4c49dSIbrahim Kanouche	}
95*46c4c49dSIbrahim Kanouche}
96*46c4c49dSIbrahim Kanouche
97*46c4c49dSIbrahim Kanouchefunc BenchmarkStringSets_Intersect(b *testing.B) {
98*46c4c49dSIbrahim Kanouche	s := NewStringSet(stringsA...)
99*46c4c49dSIbrahim Kanouche	t := NewStringSet(stringsB...)
100*46c4c49dSIbrahim Kanouche
101*46c4c49dSIbrahim Kanouche	b.ResetTimer()
102*46c4c49dSIbrahim Kanouche	for i := 0; i < b.N; i++ {
103*46c4c49dSIbrahim Kanouche		s.Intersect(t)
104*46c4c49dSIbrahim Kanouche	}
105*46c4c49dSIbrahim Kanouche}
106*46c4c49dSIbrahim Kanouche
107*46c4c49dSIbrahim Kanouchefunc BenchmarkStringSets_Disjoint(b *testing.B) {
108*46c4c49dSIbrahim Kanouche	s := NewStringSet(stringsA...)
109*46c4c49dSIbrahim Kanouche	t := NewStringSet(stringsB...)
110*46c4c49dSIbrahim Kanouche
111*46c4c49dSIbrahim Kanouche	b.ResetTimer()
112*46c4c49dSIbrahim Kanouche	for i := 0; i < b.N; i++ {
113*46c4c49dSIbrahim Kanouche		s.Disjoint(t)
114*46c4c49dSIbrahim Kanouche	}
115*46c4c49dSIbrahim Kanouche}
116*46c4c49dSIbrahim Kanouche
117*46c4c49dSIbrahim Kanouchefunc BenchmarkStringSets_Difference(b *testing.B) {
118*46c4c49dSIbrahim Kanouche	s := NewStringSet(stringsA...)
119*46c4c49dSIbrahim Kanouche	t := NewStringSet(stringsB...)
120*46c4c49dSIbrahim Kanouche
121*46c4c49dSIbrahim Kanouche	b.ResetTimer()
122*46c4c49dSIbrahim Kanouche	for i := 0; i < b.N; i++ {
123*46c4c49dSIbrahim Kanouche		s.Difference(t)
124*46c4c49dSIbrahim Kanouche	}
125*46c4c49dSIbrahim Kanouche}
126*46c4c49dSIbrahim Kanouche
127*46c4c49dSIbrahim Kanouchefunc BenchmarkStringSets_Unique(b *testing.B) {
128*46c4c49dSIbrahim Kanouche	s := NewStringSet(stringsA...)
129*46c4c49dSIbrahim Kanouche	t := NewStringSet(stringsB...)
130*46c4c49dSIbrahim Kanouche
131*46c4c49dSIbrahim Kanouche	b.ResetTimer()
132*46c4c49dSIbrahim Kanouche	for i := 0; i < b.N; i++ {
133*46c4c49dSIbrahim Kanouche		s.Unique(t)
134*46c4c49dSIbrahim Kanouche	}
135*46c4c49dSIbrahim Kanouche}
136*46c4c49dSIbrahim Kanouche
137*46c4c49dSIbrahim Kanouchefunc BenchmarkStringSets_Equal(b *testing.B) {
138*46c4c49dSIbrahim Kanouche	s := NewStringSet(stringsA...)
139*46c4c49dSIbrahim Kanouche	t := NewStringSet(stringsB...)
140*46c4c49dSIbrahim Kanouche
141*46c4c49dSIbrahim Kanouche	b.ResetTimer()
142*46c4c49dSIbrahim Kanouche	for i := 0; i < b.N; i++ {
143*46c4c49dSIbrahim Kanouche		s.Equal(t)
144*46c4c49dSIbrahim Kanouche	}
145*46c4c49dSIbrahim Kanouche}
146*46c4c49dSIbrahim Kanouche
147*46c4c49dSIbrahim Kanouchefunc BenchmarkStringSets_Union(b *testing.B) {
148*46c4c49dSIbrahim Kanouche	s := NewStringSet(stringsA...)
149*46c4c49dSIbrahim Kanouche	t := NewStringSet(stringsB...)
150*46c4c49dSIbrahim Kanouche
151*46c4c49dSIbrahim Kanouche	b.ResetTimer()
152*46c4c49dSIbrahim Kanouche	for i := 0; i < b.N; i++ {
153*46c4c49dSIbrahim Kanouche		s.Union(t)
154*46c4c49dSIbrahim Kanouche	}
155*46c4c49dSIbrahim Kanouche}
156*46c4c49dSIbrahim Kanouche
157*46c4c49dSIbrahim Kanouchefunc BenchmarkStringSets_Contains(b *testing.B) {
158*46c4c49dSIbrahim Kanouche	s := NewStringSet(stringsA...)
159*46c4c49dSIbrahim Kanouche
160*46c4c49dSIbrahim Kanouche	b.ResetTimer()
161*46c4c49dSIbrahim Kanouche	for i := 0; i < b.N; i++ {
162*46c4c49dSIbrahim Kanouche		for _, w := range stringsB {
163*46c4c49dSIbrahim Kanouche			s.Contains(w)
164*46c4c49dSIbrahim Kanouche		}
165*46c4c49dSIbrahim Kanouche	}
166*46c4c49dSIbrahim Kanouche}
167*46c4c49dSIbrahim Kanouche
168*46c4c49dSIbrahim Kanouchefunc BenchmarkStringSets_Len(b *testing.B) {
169*46c4c49dSIbrahim Kanouche	s := NewStringSet(stringsA...)
170*46c4c49dSIbrahim Kanouche
171*46c4c49dSIbrahim Kanouche	b.ResetTimer()
172*46c4c49dSIbrahim Kanouche	for i := 0; i < b.N; i++ {
173*46c4c49dSIbrahim Kanouche		s.Len()
174*46c4c49dSIbrahim Kanouche	}
175*46c4c49dSIbrahim Kanouche}
176*46c4c49dSIbrahim Kanouche
177*46c4c49dSIbrahim Kanouchefunc BenchmarkStringSets_Empty(b *testing.B) {
178*46c4c49dSIbrahim Kanouche	s := NewStringSet(stringsA...)
179*46c4c49dSIbrahim Kanouche	t := NewStringSet()
180*46c4c49dSIbrahim Kanouche
181*46c4c49dSIbrahim Kanouche	b.ResetTimer()
182*46c4c49dSIbrahim Kanouche	for i := 0; i < b.N; i++ {
183*46c4c49dSIbrahim Kanouche		s.Empty()
184*46c4c49dSIbrahim Kanouche		t.Empty()
185*46c4c49dSIbrahim Kanouche	}
186*46c4c49dSIbrahim Kanouche}
187*46c4c49dSIbrahim Kanouche
188*46c4c49dSIbrahim Kanouchefunc BenchmarkStringSets_Elements(b *testing.B) {
189*46c4c49dSIbrahim Kanouche	s := NewStringSet(stringsA...)
190*46c4c49dSIbrahim Kanouche
191*46c4c49dSIbrahim Kanouche	b.ResetTimer()
192*46c4c49dSIbrahim Kanouche	for i := 0; i < b.N; i++ {
193*46c4c49dSIbrahim Kanouche		s.Elements()
194*46c4c49dSIbrahim Kanouche	}
195*46c4c49dSIbrahim Kanouche}
196*46c4c49dSIbrahim Kanouche
197*46c4c49dSIbrahim Kanouchefunc BenchmarkStringSets_Sorted(b *testing.B) {
198*46c4c49dSIbrahim Kanouche	s := NewStringSet(stringsA...)
199*46c4c49dSIbrahim Kanouche
200*46c4c49dSIbrahim Kanouche	b.ResetTimer()
201*46c4c49dSIbrahim Kanouche	for i := 0; i < b.N; i++ {
202*46c4c49dSIbrahim Kanouche		s.Sorted()
203*46c4c49dSIbrahim Kanouche	}
204*46c4c49dSIbrahim Kanouche}
205*46c4c49dSIbrahim Kanouche
206*46c4c49dSIbrahim Kanouchefunc BenchmarkStringSets_String(b *testing.B) {
207*46c4c49dSIbrahim Kanouche	s := NewStringSet(stringsA...)
208*46c4c49dSIbrahim Kanouche
209*46c4c49dSIbrahim Kanouche	b.ResetTimer()
210*46c4c49dSIbrahim Kanouche	for i := 0; i < b.N; i++ {
211*46c4c49dSIbrahim Kanouche		s.String()
212*46c4c49dSIbrahim Kanouche	}
213*46c4c49dSIbrahim Kanouche}
214