File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
staging/src/k8s.io/apiserver/pkg/endpoints Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -1616,6 +1616,41 @@ func TestGet(t *testing.T) {
1616
1616
}
1617
1617
}
1618
1618
1619
+ func BenchmarkGet (b * testing.B ) {
1620
+ storage := map [string ]rest.Storage {}
1621
+ simpleStorage := SimpleRESTStorage {
1622
+ item : genericapitesting.Simple {
1623
+ Other : "foo" ,
1624
+ },
1625
+ }
1626
+ selfLinker := & setTestSelfLinker {
1627
+ expectedSet : "/" + prefix + "/" + testGroupVersion .Group + "/" + testGroupVersion .Version + "/namespaces/default/simple/id" ,
1628
+ name : "id" ,
1629
+ namespace : "default" ,
1630
+ }
1631
+ storage ["simple" ] = & simpleStorage
1632
+ handler := handleLinker (storage , selfLinker )
1633
+ server := httptest .NewServer (handler )
1634
+ defer server .Close ()
1635
+
1636
+ u := server .URL + "/" + prefix + "/" + testGroupVersion .Group + "/" + testGroupVersion .Version + "/namespaces/default/simple/id"
1637
+
1638
+ b .ResetTimer ()
1639
+ for i := 0 ; i < b .N ; i ++ {
1640
+ resp , err := http .Get (u )
1641
+ if err != nil {
1642
+ b .Fatalf ("unexpected error: %v" , err )
1643
+ }
1644
+ if resp .StatusCode != http .StatusOK {
1645
+ b .Fatalf ("unexpected response: %#v" , resp )
1646
+ }
1647
+ if _ , err := io .Copy (ioutil .Discard , resp .Body ); err != nil {
1648
+ b .Fatalf ("unable to read body" )
1649
+ }
1650
+ }
1651
+ b .StopTimer ()
1652
+ }
1653
+
1619
1654
func TestGetCompression (t * testing.T ) {
1620
1655
storage := map [string ]rest.Storage {}
1621
1656
simpleStorage := SimpleRESTStorage {
You can’t perform that action at this time.
0 commit comments