-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimisation of diff performace (#277)
* optimize performace of diff * Suggested changes * Added a Benchmarktest for ygot.Diff * changed errorhandling and import path * resolve syntax errors
- Loading branch information
1 parent
5fe05c9
commit 68346f9
Showing
4 changed files
with
9,141 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package validate | ||
|
||
import ( | ||
"io/ioutil" | ||
"path/filepath" | ||
"testing" | ||
|
||
oc "github.com/openconfig/ygot/exampleoc" | ||
"github.com/openconfig/ygot/ygot" | ||
) | ||
|
||
func BenchmarkDiff(b *testing.B) { | ||
jsonFileA := "interfaceBenchmarkA.json" | ||
jsonFileB := "interfaceBenchmarkB.json" | ||
|
||
jsonA, err := ioutil.ReadFile(filepath.Join(testRoot, "testdata", jsonFileA)) | ||
if err != nil { | ||
b.Errorf("ioutil.ReadFile(%s): could not open file: %v", jsonFileA, err) | ||
return | ||
} | ||
deviceA := &oc.Device{} | ||
if err := oc.Unmarshal(jsonA, deviceA); err != nil { | ||
b.Errorf("ioutil.ReadFile(%s): could unmarschal: %v", jsonFileA, err) | ||
return | ||
} | ||
|
||
jsonB, err := ioutil.ReadFile(filepath.Join(testRoot, "testdata", jsonFileB)) | ||
if err != nil { | ||
b.Errorf("ioutil.ReadFile(%s): could not open file: %v", jsonFileB, err) | ||
return | ||
} | ||
deviceB := &oc.Device{} | ||
if err := oc.Unmarshal(jsonB, deviceB); err != nil { | ||
b.Errorf("ioutil.ReadFile(%s): could unmarschal: %v", jsonFileB, err) | ||
return | ||
} | ||
_, err = ygot.Diff(deviceA, deviceB) | ||
if err != nil { | ||
b.Errorf("Error in diff %v", err) | ||
return | ||
} | ||
} |
Oops, something went wrong.