2014-06-26 3 views
7

gocheck परीक्षण ढांचे के साथ बेंचमार्क के लिए ध्वज विकल्पों का उपयोग कैसे करता है? मेरे द्वारा प्रदान किए गए लिंक में ऐसा लगता है कि वे प्रदान करते हैं कि एकमात्र उदाहरण go test -check.b चलाकर है, हालांकि, वे यह कैसे काम करते हैं इसके बारे में अतिरिक्त टिप्पणियां प्रदान नहीं करते हैं, इसलिए इसका उपयोग करना मुश्किल है। जब मैं go help test करता था और न ही मैंने go help testflag किया था, तब भी मुझे दस्तावेज में चेक नहीं मिला। विशेष रूप से मैं कैसे बेंचमार्क परीक्षण ढांचे बेहतर उपयोग करने के लिए जानना चाहता हूँ और उन्हें नियंत्रित करने के लिए समय लगता है या के लिए चलाता है कि कितने पुनरावृत्तियों यह उदाहरण में आदि आदि के लिए चलाता है उदाहरण के लिए वे प्रदान करते हैं:गो (गोलांग) गोचेक परीक्षण ढांचे के लिए आप बेंचमार्क झंडे का उपयोग कैसे करते हैं?

func (s *MySuite) BenchmarkLogic(c *C) { 
    for i := 0; i < c.N; i++ { 
     // Logic to benchmark 
    } 
} 

नहीं है परिवर्तनीय सीएन एक वैरिएबल निर्दिष्ट कैसे करता है? क्या यह वास्तविक कार्यक्रम के माध्यम से है या यह परीक्षण और उसके झंडे या कमांड लाइन के माध्यम से है?

ओर टिप्पणी पर, go help testflag से प्रलेखन -bench regex के बारे में, benchmem और benchtime t विकल्पों बात की, हालांकि, यह -check.b विकल्प के बारे में बात नहीं करता है। हालांकि मैंने वहां वर्णित अनुसार इन विकल्पों को चलाने का प्रयास किया लेकिन वास्तव में ऐसा कुछ भी नहीं किया जो मैं देख सकता था। क्या Gocheck go test के लिए मूल विकल्पों के साथ काम करता है?

मुझे लगता है कि मुख्य समस्या यह है कि gocheck उपकरण या उसके आदेशों का उपयोग करने के लिए कोई स्पष्ट दस्तावेज़ीकरण नहीं है। मैं गलती से इसे एक गलत झंडा दिया और यह मेरे लिए उपयोगी आज्ञाओं है कि मैं (जो सीमित वर्णन) की जरूरत का सुझाव दे एक त्रुटि संदेश फेंक दिया:

-check.b=false: Run benchmarks 
    -check.btime=1s: approximate run time for each benchmark 
    -check.f="": Regular expression selecting which tests and/or suites to run 
    -check.list=false: List the names of all tests that will be run 
    -check.v=false: Verbose mode 
    -check.vv=false: Super verbose mode (disables output caching) 
    -check.work=false: Display and do not remove the test working directory 
    -gocheck.b=false: Run benchmarks 
    -gocheck.btime=1s: approximate run time for each benchmark 
    -gocheck.f="": Regular expression selecting which tests and/or suites to run 
    -gocheck.list=false: List the names of all tests that will be run 
    -gocheck.v=false: Verbose mode 
    -gocheck.vv=false: Super verbose mode (disables output caching) 
    -gocheck.work=false: Display and do not remove the test working directory 
    -test.bench="": regular expression to select benchmarks to run 
    -test.benchmem=false: print memory allocations for benchmarks 
    -test.benchtime=1s: approximate run time for each benchmark 
    -test.blockprofile="": write a goroutine blocking profile to the named file after execution 
    -test.blockprofilerate=1: if >= 0, calls runtime.SetBlockProfileRate() 
    -test.coverprofile="": write a coverage profile to the named file after execution 
    -test.cpu="": comma-separated list of number of CPUs to use for each test 
    -test.cpuprofile="": write a cpu profile to the named file during execution 
    -test.memprofile="": write a memory profile to the named file after execution 
    -test.memprofilerate=0: if >=0, sets runtime.MemProfileRate 
    -test.outputdir="": directory in which to write profiles 
    -test.parallel=1: maximum test parallelism 
    -test.run="": regular expression to select tests and examples to run 
    -test.short=false: run smaller test suite to save time 
    -test.timeout=0: if positive, sets an aggregate time limit for all tests 
    -test.v=false: verbose: print additional output 

गलत लिख इस उपकरण के साथ कुछ मदद पाने के लिए एक ही रास्ता आदेश है? इसमें कोई मदद ध्वज या कुछ नहीं है?

उत्तर

3

Description_of_testing_flags देखें:

-bench regexp 
    Run benchmarks matching the regular expression. 
    By default, no benchmarks run. To run all benchmarks, 
    use '-bench .' or '-bench=.'. 

-check.b-test.bench जैसा ही होता है।

उदा। सभी मानक को चलाने के लिए:

go test -check.b=BenchmarkLogic 

अधिक जाओ में परीक्षण के बारे में जानकारी पाया जा सकता है here

+0

कृपया संशोधित '' 'जाना परीक्षण -check.b =:

go test -check.b=. 

एक विशिष्ट बेंचमार्क चलाने के लिए '' '' '' 'test-check.b''' '' '' ''परीक्षा के साथ - gocheck.b'''' '' – hoenir

संबंधित मुद्दे