Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data of how many times swapNodes was called on each row #202

Open
kcalvinalvin opened this issue Sep 24, 2020 · 0 comments
Open

Data of how many times swapNodes was called on each row #202

kcalvinalvin opened this issue Sep 24, 2020 · 0 comments

Comments

@kcalvinalvin
Copy link
Member

kcalvinalvin commented Sep 24, 2020

Per @adiabat's suggestion, I collected the data on how many swapNodes() were called in each row. This was done by putting a println: fmt.Printf("swapNodes on row:%05d, forestRows:%05d\n", r, f.rows)

above this line.

f.swapNodes(swap, r)

Figure_1

row 0: COUNT: 14266400
row 1: COUNT: 8382600
row 2: COUNT: 4746562
row 3: COUNT: 2648818
row 4: COUNT: 1406879
row 5: COUNT: 722279
row 6: COUNT: 358039
row 7: COUNT: 170496
row 8: COUNT: 79073
row 9: COUNT: 35974
row 10: COUNT: 15880
row 11: COUNT: 7146
row 12: COUNT: 3140
row 13: COUNT: 1330
row 14: COUNT: 504
row 15: COUNT: 203
row 16: COUNT: 70
row 17: COUNT: 41
row 18: COUNT: 15
row 19: COUNT: 6
row 20: COUNT: 0
row 21: COUNT: 2
row 22: COUNT: 0
row 23: COUNT: 0
row 24: COUNT: 0
row 25: COUNT: 0

used this bash script to extract from the log

  #!/usr/bin/env bash

  # set file
  FILE=$1

  getRow() {
          COUNT=0
          #cat $FILE | while read line; do
          while read line; do
                  printf -v j "%5d" $i
                  #echo "swapNodes on row:     $1"
                  if [[ $line == *"swapNodes on row:$j"* ]]; then
                          #echo MATCH
                          COUNT=$(($COUNT+1))
                          #echo $COUNT
                  fi
          done < $2

          echo "row $1: COUNT: $COUNT"
  }

  MAXNUM=$2

  echo "For forestRows=$MAXNUM"
  echo

  for i in $(seq 0 $MAXNUM); do
          #grep "swapNodes on row:    0"
          #$COUNT = $COUNT + 1
          getRow $i $FILE
          #printf "%5d\n" $i

And this python script for the graph

import matplotlib.pyplot as plt
import matplotlib.ticker as plticker
import numpy as np

TEST = [
    14266400,
    8382600,
    4746562,
    2648818,
    1406879,
    722279,
    358039,
    170496,
    79073,
    35974,
    15880,
    7146,
    3140,
    1330,
    504,
    203,
    70,
    41,
    15,
    6,
    0,
    2,
    0,
    0,
    0,
    0,
]

fig, ax = plt.subplots()

#fig.set_figheight(10)
#fig.set_figwidth(20)

ax.bar(np.arange(26), TEST, linewidth=5)
ax.ticklabel_format(useOffset=False, style='plain')

plt.xticks(np.arange(26))

for index, data in enumerate(TEST):
    plt.text(x=index-0.1, y=data, s=data, fontdict=dict(fontsize=7))

plt.title("Utreexo calls on rows. (testnet3 to block #1747721)")
plt.xlabel("rows called")
plt.ylabel("how many times called on each row")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant