Debian Codegraph @

common/cost.go

raw symbols SCIP
1 // Copyright 2022 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package common
16
17 const (
18 // SelectAndIdentCost is the cost of an operation that accesses an identifier or performs a select.
19 SelectAndIdentCost = 1
20
21 // ConstCost is the cost of an operation that accesses a constant.
22 ConstCost = 0
23
24 // ListCreateBaseCost is the base cost of any operation that creates a new list.
25 ListCreateBaseCost = 10
26
27 // MapCreateBaseCost is the base cost of any operation that creates a new map.
28 MapCreateBaseCost = 30
29
30 // StructCreateBaseCost is the base cost of any operation that creates a new struct.
31 StructCreateBaseCost = 40
32
33 // StringTraversalCostFactor is multiplied to a length of a string when computing the cost of traversing the entire
34 // string once.
35 StringTraversalCostFactor = 0.1
36
37 // RegexStringLengthCostFactor is multiplied ot the length of a regex string pattern when computing the cost of
38 // applying the regex to a string of unit cost.
39 RegexStringLengthCostFactor = 0.25
40 )