Exemplo n.º 1
0
Arquivo: main.go Projeto: postfix/fwk
func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, `Usage: %[1]s [options] <input-file> <output-file>

ex:
 $ %[1]s -l=INFO -evtmax=-1 ./input.ascii ./output.ascii

options:
`,
			os.Args[0],
		)
		flag.PrintDefaults()
	}

	flag.Parse()

	start := time.Now()
	fmt.Printf("::: %s...\n", os.Args[0])

	// create a default fwk application, with some properties
	// extracted from the CLI
	app := job.NewJob(nil, job.P{
		"EvtMax":   *evtmax,
		"NProcs":   *nprocs,
		"MsgLevel": job.MsgLevel(*lvl),
	})

	app.Create(job.C{
		Type: "main.testhsvc",
		Name: "t-01",
		Props: job.P{
			"Stream": "/my-hist",
		},
	})

	app.Create(job.C{
		Type: "main.testhsvc",
		Name: "t-02",
		Props: job.P{
			"Stream": "/my-hist",
		},
	})

	app.Create(job.C{
		Type: "github.com/go-hep/fwk/hbooksvc.hsvc",
		Name: "histsvc",
		Props: job.P{
			"Streams": map[string]hbooksvc.Stream{
				"/my-hist": {
					Name: "hist.rio",
					Mode: hbooksvc.Read,
				},
			},
		},
	})

	app.Run()
	fmt.Printf("::: %s... [done] (cpu=%v)\n", os.Args[0], time.Since(start))
}
Exemplo n.º 2
0
func newapp(evtmax int64, nprocs int) *job.Job {
	app := job.NewJob(nil, job.P{
		"EvtMax":   evtmax,
		"NProcs":   nprocs,
		"MsgLevel": job.MsgLevel("ERROR"),
	})
	return app
}
Exemplo n.º 3
0
Arquivo: main.go Projeto: postfix/fwk
func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, `Usage: %[1]s [options]

ex:
 $ %[1]s -l=INFO -evtmax=-1

options:
`,
			os.Args[0],
		)
		flag.PrintDefaults()
	}

	flag.Parse()

	start := time.Now()
	fmt.Printf("::: %s...\n", os.Args[0])

	// create a default fwk application, with some properties
	// extracted from the CLI
	app := job.New(job.P{
		"EvtMax":   *evtmax,
		"NProcs":   *nprocs,
		"MsgLevel": job.MsgLevel(*lvl),
	})

	// create a task that reads integers from some location
	// and publish the square of these integers under some other location
	app.Create(job.C{
		Type: "github.com/go-hep/fwk/testdata.task2",
		Name: "t2",
		Props: job.P{
			"Input":  "t1-ints1",
			"Output": "t1-ints1-massaged",
		},
	})

	// create a task that publish integers to some location(s)
	// note we create it after the one that consumes these integers
	// to exercize the automatic data-flow scheduling.
	app.Create(job.C{
		Type: "github.com/go-hep/fwk/testdata.task1",
		Name: "t1",
		Props: job.P{
			"Ints1": "t1-ints1",
			"Ints2": "t2-ints2",
			"Int1":  int64(10), // value for the Ints1
			"Int2":  int64(20), // value for the Ints2
		},
	})

	// run the application
	app.Run()

	fmt.Printf("::: %s... [done] (cpu=%v)\n", os.Args[0], time.Since(start))
}
Exemplo n.º 4
0
Arquivo: main.go Projeto: postfix/fwk
func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, `Usage: fwk-cpu-cruncher [options] <config-file>

ex:
 $ fwk-cpu-cruncher -l=INFO -evtmax=100 ./testdata/athena.json

options:
`,
		)
		flag.PrintDefaults()
	}

	flag.Parse()

	if flag.NArg() <= 0 {
		fmt.Fprintf(os.Stderr, "** error: needs an input cpu-cruncher configuration file\n")
		flag.Usage()
		os.Exit(1)
	}
	fname := flag.Arg(0)

	start := time.Now()

	fmt.Printf("::: fwk-cpu-cruncher...\n")
	if *cpu {
		f, err := os.Create("cpu.prof")
		if err != nil {
			panic(err)
		}
		defer f.Close()
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	app := job.New(job.P{
		"EvtMax":   int64(*evtmax),
		"NProcs":   *nprocs,
		"MsgLevel": job.MsgLevel(*lvl),
	})

	if *dotfile != "" {
		dflow := app.App().GetSvc("dataflow")
		if dflow == nil {
			panic(fmt.Errorf("could not retrieve dataflow service"))
		}

		app.SetProp(dflow, "DotFile", *dotfile)
	}

	loadConfig(fname, app)

	app.Run()
	fmt.Printf("::: fwk-cpu-cruncher... [done] (time=%v)\n", time.Since(start))
}
Exemplo n.º 5
0
Arquivo: main.go Projeto: postfix/fwk
func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, `Usage: %[1]s [options] <input-file> <output-file>

ex:
 $ %[1]s -l=INFO -evtmax=100 ./input.rio ./output.rio

options:
`,
			os.Args[0],
		)
		flag.PrintDefaults()
	}

	flag.Parse()

	input := "input.rio"
	if flag.NArg() > 0 {
		input = flag.Arg(0)
	}

	output := "output.rio"
	if flag.NArg() > 1 {
		output = flag.Arg(1)
	}

	start := time.Now()
	fmt.Printf("::: %s...\n", os.Args[0])

	// create a default fwk application, with some properties
	// extracted from the CLI
	app := job.New(job.P{
		"EvtMax":   *evtmax,
		"NProcs":   *nprocs,
		"MsgLevel": job.MsgLevel(*lvl),
	})

	// create a task that reads integers from some location
	// and publish the square of these integers under some other location
	app.Create(job.C{
		Type: "github.com/go-hep/fwk/testdata.task2",
		Name: "t2",
		Props: job.P{
			"Input":  "t1-ints1-massaged",
			"Output": "t1-ints1-massaged-new",
		},
	})

	// create an input-stream, reading from some io.Reader
	// note we create it after the one that consumes these integers
	// to exercize the automatic data-flow scheduling.
	app.Create(job.C{
		Type: "github.com/go-hep/fwk.InputStream",
		Name: "input",
		Props: job.P{
			"Ports": []fwk.Port{
				{
					Name: "t1-ints1-massaged",      // location where to publish our data
					Type: reflect.TypeOf(int64(0)), // type of that data
				},
			},
			"Streamer": &rio.InputStreamer{
				Names: []string{input},
			},
		},
	})

	// output
	app.Create(job.C{
		Type: "github.com/go-hep/fwk.OutputStream",
		Name: "rio-output",
		Props: job.P{
			"Ports": []fwk.Port{
				{
					Name: "t1-ints1-massaged-new",  // location of data to write out
					Type: reflect.TypeOf(int64(0)), // type of that data
				},
			},
			"Streamer": &rio.OutputStreamer{
				Name: output,
			},
		},
	})

	// run the application
	app.Run()

	fmt.Printf("::: %s... [done] (cpu=%v)\n", os.Args[0], time.Since(start))
}
Exemplo n.º 6
0
func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, `Usage: fwk-ex-tuto1 [options] <input-file> <output-file>

ex:
 $ %[1]s -l=INFO -evtmax=-1 ./input.ascii ./output.ascii

options:
`,
			os.Args[0],
		)
		flag.PrintDefaults()
	}

	flag.Parse()

	ifname := "input.ascii"
	if flag.NArg() > 0 {
		ifname = flag.Arg(0)
	}

	ofname := "output.ascii"
	if flag.NArg() > 1 {
		ofname = flag.Arg(1)
	}

	start := time.Now()
	fmt.Printf("::: %s...\n", os.Args[0])

	// create a default fwk application, with some properties
	// extracted from the CLI
	app := job.New(job.P{
		"EvtMax":   *g_evtmax,
		"NProcs":   *g_nprocs,
		"MsgLevel": job.MsgLevel(*g_lvl),
	})

	r, err := os.Open(ifname)
	if err != nil {
		app.Errorf("could not open input file [%s]: %v\n", ifname, err)
		os.Exit(1)
	}
	defer r.Close()

	w, err := os.Create(ofname)
	if err != nil {
		app.Errorf("could not create output file [%s]: %v\n", ofname, err)
		os.Exit(1)
	}
	defer w.Close()

	// create a task that reads integers from some location
	// and publish the square of these integers under some other location
	app.Create(job.C{
		Type: "github.com/go-hep/fwk/testdata.task2",
		Name: "t2",
		Props: job.P{
			"Input":  "t1-ints1",
			"Output": "t1-ints1-massaged",
		},
	})

	// create an input-stream, reading from some io.Reader
	// note we create it after the one that consumes these integers
	// to exercize the automatic data-flow scheduling.
	app.Create(job.C{
		Type: "github.com/go-hep/fwk.InputStream",
		Name: "input",
		Props: job.P{
			"Ports": []fwk.Port{
				{
					Name: "t1-ints1",               // location where to publish our data
					Type: reflect.TypeOf(int64(0)), // type of that data
				},
			},
			"Streamer": &testdata.InputStream{
				R: r,
			},
		},
	})

	// create an output-stream
	app.Create(job.C{
		Type: "github.com/go-hep/fwk.OutputStream",
		Name: "output",
		Props: job.P{
			"Ports": []fwk.Port{
				{
					Name: "t1-ints1-massaged",      // location of data to write out
					Type: reflect.TypeOf(int64(0)), // type of that data
				},
			},
			"Streamer": &testdata.OutputStream{
				W: w,
			},
		},
	})

	// run the application
	app.Run()

	fmt.Printf("::: %s... [done] (cpu=%v)\n", os.Args[0], time.Since(start))
}