dataToKnowlede.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. package main
  2. import (
  3. "bufio"
  4. "fmt"
  5. "log"
  6. "os"
  7. "strconv"
  8. "strings"
  9. )
  10. func main() {
  11. //calculates avg publisher %
  12. var pubPerc float64
  13. var counter float64
  14. f1, err := os.Open("evalData_500_5_Full_Pad")
  15. if err != nil {
  16. log.Fatal(err)
  17. }
  18. defer f1.Close()
  19. scanner1 := bufio.NewScanner(f1)
  20. for scanner1.Scan() {
  21. if strings.Contains(scanner1.Text(), "currentPublisherAmount") {
  22. counter++
  23. textArr := strings.Split(scanner1.Text(), " ")
  24. num, err := strconv.ParseFloat(textArr[len(textArr)-1], 64)
  25. if err != nil {
  26. panic(err)
  27. }
  28. pubPerc += num
  29. }
  30. }
  31. fmt.Println("pubPercentage", pubPerc/counter)
  32. //calculates avg db Size
  33. f2, err := os.Open("evalData_1000_5_278_Pad")
  34. if err != nil {
  35. log.Fatal(err)
  36. }
  37. defer f2.Close()
  38. scanner2 := bufio.NewScanner(f2)
  39. counter = 0
  40. var dbSizeAvg float64
  41. for scanner2.Scan() {
  42. if strings.Contains(scanner2.Text(), "dbWriteSize") {
  43. counter++
  44. textArr := strings.Split(scanner2.Text(), " ")
  45. num, err := strconv.ParseFloat(textArr[len(textArr)-1], 64)
  46. if err != nil {
  47. panic(err)
  48. }
  49. dbSizeAvg += num
  50. }
  51. }
  52. fmt.Println("dbSizeAvg", dbSizeAvg/counter)
  53. f2, err = os.Open("evalData_1000_5_278_Pad")
  54. if err != nil {
  55. log.Fatal(err)
  56. }
  57. defer f2.Close()
  58. scanner3 := bufio.NewScanner(f2)
  59. counter = 0
  60. var collPerc float64
  61. for scanner3.Scan() {
  62. if strings.Contains(scanner3.Text(), "dbWriteSize") {
  63. counter++
  64. textArr := strings.Split(scanner3.Text(), " ")
  65. num, err := strconv.ParseFloat(textArr[len(textArr)-3], 64)
  66. if err != nil {
  67. panic(err)
  68. }
  69. collPerc += num
  70. }
  71. }
  72. fmt.Println("collPerc", collPerc/counter)
  73. f1, err = os.Open("evalData_500_5_Full_Pad")
  74. if err != nil {
  75. log.Fatal(err)
  76. }
  77. defer f1.Close()
  78. scanner4 := bufio.NewScanner(f1)
  79. counter = 0
  80. var bytesSavedPerc float64
  81. row := 0
  82. for scanner4.Scan() {
  83. row++
  84. if row < 680 {
  85. continue
  86. }
  87. if strings.Contains(scanner4.Text(), "bytesSaved") {
  88. counter++
  89. textArr := strings.Split(scanner4.Text(), " ")
  90. num, err := strconv.ParseFloat(textArr[len(textArr)-1], 64)
  91. if err != nil {
  92. panic(err)
  93. }
  94. bytesSavedPerc += num
  95. }
  96. }
  97. fmt.Println("bytesSavedPerc", bytesSavedPerc/counter)
  98. f1, err = os.Open("evalDataClient_500_5_Full_Pad")
  99. if err != nil {
  100. log.Fatal(err)
  101. }
  102. defer f1.Close()
  103. scanner5 := bufio.NewScanner(f1)
  104. counter = 0
  105. var goodPadding float64
  106. row = 0
  107. for scanner5.Scan() {
  108. row++
  109. if strings.Contains(scanner5.Text(), "goodPadding Percentage") {
  110. counter++
  111. textArr := strings.Split(scanner5.Text(), " ")
  112. numText := textArr[len(textArr)-1]
  113. if numText != "NaN" {
  114. num, err := strconv.ParseFloat(numText, 64)
  115. if err != nil {
  116. panic(err)
  117. }
  118. goodPadding += num
  119. }
  120. }
  121. }
  122. fmt.Println("goodPadding", goodPadding/counter)
  123. f1, err = os.Open("evalData_1000_1_124_NoPad")
  124. if err != nil {
  125. log.Fatal(err)
  126. }
  127. defer f1.Close()
  128. scanner6 := bufio.NewScanner(f1)
  129. f2, err = os.Open("evalData_1000_1_52_Pad")
  130. if err != nil {
  131. log.Fatal(err)
  132. }
  133. defer f2.Close()
  134. scanner7 := bufio.NewScanner(f2)
  135. counter1 := 0
  136. counter2 := 0
  137. var phase3Dur1 float64
  138. var phase3Dur2 float64
  139. for scanner6.Scan() {
  140. if strings.Contains(scanner6.Text(), "fullDurationPhase3") {
  141. counter1++
  142. textArr := strings.Split(scanner6.Text(), " ")
  143. num, err := strconv.ParseFloat(textArr[len(textArr)-1], 64)
  144. if err != nil {
  145. panic(err)
  146. }
  147. phase3Dur1 += num
  148. }
  149. }
  150. for scanner7.Scan() {
  151. if strings.Contains(scanner7.Text(), "fullDurationPhase3") {
  152. counter2++
  153. textArr := strings.Split(scanner7.Text(), " ")
  154. num, err := strconv.ParseFloat(textArr[len(textArr)-1], 64)
  155. if err != nil {
  156. panic(err)
  157. }
  158. phase3Dur2 += num
  159. }
  160. }
  161. phase3Avg1 := phase3Dur1 / float64(counter1)
  162. phase3Avg2 := phase3Dur2 / float64(counter2)
  163. fmt.Println("avgDuration increase with padding", phase3Avg2/phase3Avg1)
  164. }