[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [tor-dev] Comparing Stem, metrics-lib, and zoossh
- To: Karsten Loesing <karsten@xxxxxxxxxxxxxx>
- Subject: Re: [tor-dev] Comparing Stem, metrics-lib, and zoossh
- From: Philipp Winter <phw@xxxxxxxxx>
- Date: Wed, 13 Jan 2016 10:28:25 -0500
- Cc: Damian Johnson <atagar@xxxxxxxxxxxxxx>, iwakeh <iwakeh@xxxxxxxxxxxxxxxxxxxx>, "tor-dev@xxxxxxxxxxxxxxxxxxxx" <tor-dev@xxxxxxxxxxxxxxxxxxxx>
- Delivered-to: archiver@xxxxxxxx
- Delivery-date: Wed, 13 Jan 2016 10:28:41 -0500
- In-reply-to: <5694BC03.9040709@xxxxxxxxxxxxxx>
- List-archive: <http://lists.torproject.org/pipermail/tor-dev/>
- List-help: <mailto:tor-dev-request@lists.torproject.org?subject=help>
- List-id: discussion regarding Tor development <tor-dev.lists.torproject.org>
- List-post: <mailto:tor-dev@lists.torproject.org>
- List-subscribe: <https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev>, <mailto:tor-dev-request@lists.torproject.org?subject=subscribe>
- List-unsubscribe: <https://lists.torproject.org/cgi-bin/mailman/options/tor-dev>, <mailto:tor-dev-request@lists.torproject.org?subject=unsubscribe>
- Mail-followup-to: Karsten Loesing <karsten@xxxxxxxxxxxxxx>, Damian Johnson <atagar@xxxxxxxxxxxxxx>, iwakeh <iwakeh@xxxxxxxxxxxxxxxxxxxx>, "tor-dev@xxxxxxxxxxxxxxxxxxxx" <tor-dev@xxxxxxxxxxxxxxxxxxxx>
- References: <560BA3E7.2020109@xxxxxxxxxxxxxx> <560CE098.1040201@xxxxxxxxxxxxxx> <568960BA.50409@xxxxxxxxxxxxxx> <CAJdkzEOjpW8XzO_uiMOQ_qtmqS7u3yek2uoCM_bqAgW7-WfF7g@xxxxxxxxxxxxxx> <568E8C1B.3000502@xxxxxxxxxxxxxx> <CAJdkzENCriZRwc4YickPbo2wU4ztOshw07mGBGVS+gnyODA5yA@xxxxxxxxxxxxxx> <5694BC03.9040709@xxxxxxxxxxxxxx>
- Reply-to: tor-dev@xxxxxxxxxxxxxxxxxxxx
- Sender: "tor-dev" <tor-dev-bounces@xxxxxxxxxxxxxxxxxxxx>
On Tue, Jan 12, 2016 at 09:40:35AM +0100, Karsten Loesing wrote:
> Philipp, would you be able to write the Zoossh counterpart for the
> descriptor types supported by it?
I attached a small tool that should do the same thing Damian's script
does for consensuses and server descriptors. Note, however, that it
cannot processed tar archives. It expects as input directories that
contain consensuses and server descriptors.
You can compile it with "go build benchmark.go".
Cheers,
Philipp
package main
import (
"fmt"
"log"
"os"
"path/filepath"
"time"
"git.torproject.org/user/phw/zoossh.git"
)
var processedCons int64 = 0
var processedDescs int64 = 0
var totalExits int64 = 0
var totalRelays int64 = 0
var totalBw uint64 = 0
func Min(a uint64, b uint64, c uint64) uint64 {
min := a
if b < min {
min = b
}
if c < min {
min = c
}
return min
}
func ProcessDescriptors(path string, info os.FileInfo, err error) error {
if _, err := os.Stat(path); err != nil {
return err
}
if info.IsDir() {
return nil
}
consensus, err := zoossh.ParseDescriptorFile(path)
if err != nil {
return err
}
if (processedDescs % 100) == 0 {
fmt.Printf(".")
}
for _, getDesc := range consensus.RouterDescriptors {
desc := getDesc()
totalBw += Min(desc.BandwidthAvg, desc.BandwidthBurst, desc.BandwidthObs)
processedDescs++
}
return nil
}
func ProcessConsensus(path string, info os.FileInfo, err error) error {
if _, err := os.Stat(path); err != nil {
return err
}
if info.IsDir() {
return nil
}
consensus, err := zoossh.ParseConsensusFile(path)
if err != nil {
return err
}
fmt.Printf(".")
for _, getStatus := range consensus.RouterStatuses {
status := getStatus()
totalRelays++
if status.Flags.Exit == true {
totalExits++
}
}
processedCons++
return nil
}
func main() {
if len(os.Args) != 3 {
log.Fatalf("Usage: %s CONSENSUS_ARCHIVE DESCRIPTOR_ARCHIVE", os.Args[0])
}
before := time.Now()
filepath.Walk(os.Args[1], ProcessConsensus)
fmt.Println()
after := time.Now()
duration := after.Sub(before)
fmt.Println("Total time for consensuses:", duration)
fmt.Printf("Time per consensus: %dms\n",
duration.Nanoseconds()/processedCons/int64(1000000))
fmt.Printf("Processed %d consensuses with %d router status entries.\n",
processedCons, totalRelays)
fmt.Printf("Total exits: %d\n", totalExits)
before = time.Now()
filepath.Walk(os.Args[2], ProcessDescriptors)
fmt.Println()
after = time.Now()
duration = after.Sub(before)
fmt.Println("Total time for descriptors:", duration)
fmt.Printf("Time per descriptor: %dns\n",
duration.Nanoseconds()/processedDescs)
fmt.Printf("Processed %d descriptors.\n", processedDescs)
fmt.Printf("Average advertised bandwidth: %d\n", totalBw/uint64(processedDescs))
}
_______________________________________________
tor-dev mailing list
tor-dev@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev
- References:
- Re: [tor-dev] Comparing Stem, metrics-lib, and zoossh
- Re: [tor-dev] Comparing Stem, metrics-lib, and zoossh
- Re: [tor-dev] Comparing Stem, metrics-lib, and zoossh
- Re: [tor-dev] Comparing Stem, metrics-lib, and zoossh
- Re: [tor-dev] Comparing Stem, metrics-lib, and zoossh