[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH RFC 42/59] plan: Allow "templating" from other runs



From: George Dunlap <george.dunlap@xxxxxxxxxx>

Allow 'plan' to use an existing run as a "template": load the template,
discard the runs, and save the result in the new file.

Use like this:

./schedbench -t 18.bench -f 20.bench plan

This will make 20 with an empty plan identical to that in 18.

Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxx>
---
 main.go | 38 +++++++++++++++++++++++++++++++++-----
 plan.go | 32 ++++++++++++++++++++++++++++++--
 2 files changed, 63 insertions(+), 7 deletions(-)

diff --git a/main.go b/main.go
index 8cbd708..ead6ab0 100644
--- a/main.go
+++ b/main.go
@@ -30,6 +30,7 @@ func main() {
 
        Args = Args[1:]
        filename := "test.bench"
+       template := ""
        verbosity := 0
 
        for len(Args) > 0 {
@@ -41,6 +42,13 @@ func main() {
                        }
                        filename = Args[1]
                        Args = Args[2:]
+               case "-t":
+                       if len(Args) < 2 {
+                               fmt.Println("Need arg for -t")
+                               os.Exit(1)
+                       }
+                       template = Args[1]
+                       Args = Args[2:]
                case "-v":
                        if len(Args) < 2 {
                                fmt.Println("Need arg for -v")
@@ -49,20 +57,40 @@ func main() {
                        verbosity, _ = strconv.Atoi(Args[1])
                        Args = Args[2:]
                case "plan":
-                       plan, err := LoadBenchmark(filename)
+                       // Load either the template benchmark or the filename
+                       loadfile := filename
+                       if template != "" {
+                               loadfile = template
+                       }
+                       plan, err := LoadBenchmark(loadfile)
                        if err != nil {
-                               fmt.Println("Loading benchmark ", filename, " 
", err)
+                               fmt.Printf("Loading benchmark %s: %v\n",
+                                       loadfile, err)
                                os.Exit(1)
                        }
+
+                       if template != "" {
+                               plan.filename = filename
+                               err = plan.ClearRuns()
+                               if err != nil {
+                                       fmt.Printf("Clearing runs: %v\n",
+                                               err)
+                                       os.Exit(1)
+                               }
+                       }
                        
-                       plan.ExpandInput()
+                       err = plan.ExpandInput()
+                       if err != nil {
+                               fmt.Printf("Expanding plan: %v\n", err)
+                               os.Exit(1)
+                       }
 
                        err = plan.Save()
                        if err != nil {
-                               fmt.Println("Saving plan ", filename, " ", err)
+                               fmt.Printf("Saving plan %s: %v\n", filename, 
err)
                                os.Exit(1)
                        }
-                       fmt.Println("Created plan in ", filename)
+                       fmt.Printf("Created plan in %s\n", filename)
                        Args = Args[1:]
                case "run":
                        plan, err := LoadBenchmark(filename)
diff --git a/plan.go b/plan.go
index 24c6bd4..e535603 100644
--- a/plan.go
+++ b/plan.go
@@ -1,3 +1,21 @@
+/*
+ * Copyright (C) 2016 George W. Dunlap, Citrix Systems UK Ltd
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of the
+ * License only.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
 package main
 
 import (
@@ -19,15 +37,25 @@ var WorkerPresets = map[string]WorkerParams{
        "P001":WorkerParams{[]string{"burnwait", "70", "200000"}},
 }
 
+func (plan *BenchmarkPlan) ClearRuns() (err error) {
+       plan.Runs = nil
+
+       return
+}
 
 func (plan *BenchmarkPlan) ExpandInput() (err error) {
        if plan.Runs != nil {
-               fmt.Printf("plan.Expand: Runs non-empty, not doing anything\n");
+               err = fmt.Errorf("Runs non-empty, not doing anything\n");
+               return
+       }
+
+       if plan.Input == nil {
+               err = fmt.Errorf("Input nil, nothing to do")
                return
        }
        
        if plan.Input.SimpleMatrix == nil {
-               fmt.Printf("plan.Expand: SimpleMatrix nil, nothing to do\n");
+               err = fmt.Errorf("Input.SimpleMatrix nil, nothing to do\n");
                return
        }
 
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.