The beginning of the standard
Items | Answers |
---|---|
GIT address | GIT |
GIT Username | homlex |
After school number 5 | 62618 |
blog address | Blog Home |
Work address | Work address |
First, cloned from another user to a local warehouse
process | Operation Record |
---|---|
The first step: fork | |
Step two: clone | |
Third Step: Installation Configuration | |
The fourth step: to complete the boot |
Second, create a project and coding.
Create a project:
Create a C # .NET project, ConsoleApp, renamed Calculator.
Design ideas are as follows:
Design of a class MyRandom , then for generating a random number and operator operations. (In order to facilitate subsequent calculations, where all of the digital type is set to string, the latter will consider redesigning into digital data type.)
Design of a Formular class, for combining the random number and the random number and the random symbols, and get the result, a method comprising, to get a complete set of equations, such as: { "5 + 6 × 3-1 = 22", "3 + 2-5 × 0 = 5 ", "8 × 2-6 ÷ 2 = 13"}
Design WriteFile class, a save (string, List <string> ) method, save for the expression of the generated files.
Other details do not do too much introduction. Next is the encoding time.
。。。。。。
After some "Code And Fix", the first generation has been encoded finished:
run. The results are as follows.
Third, unit testing
What I did:
Right inside the Executioner class -> create unit tests -> OK
The result: you can see the results of the test method for Calc Executioner's all through
Next, a method Formular GetFullExpressions class Test:
Breakpoint debugging (set breakpoints in GetResult method Formular, and then start the debugger)
Program stops at the breakpoint. Single-step execution can observe the local variables, etc. and other debugging information at the bottom after a few.
Performance view.
The number of first four operations to produce the change in the form of hard-coded 1 million , then
ALT+F2
, checkCPU Usage
, click below to get started.After 1 minute 13 seconds to generate a test report .
We can see Formular maximum occupancy rate of the CPU, mainly because this class not only to produce but also to obtain expression results, so you can see its share of almost 100%. But other methods is low, it may be the beginning of the design caused by the uneven distribution of responsibilities. GetRandomNum about 10% higher than GetRandomOpt, and this is in line with expectations, because every time data is generated, the former than the latter to be called once.
Generate a detailed report: click here:
He will generate a vspx file, we can look at some of the details of running.
From the whole, consumption of the CPU is relatively stable. Randomly selected three time points: see substantially balanced utilization of 12%.
After the feed point can see some details of its maximum occupancy after GetFullExpressions method.
Fourth, cloning and upload
Clone: The above has already been illustrated , here only records the procedure code upload.
Next came directory, right open gitbash
The main performed
bash
as follows:$ git config --global user.email "[email protected]" $ git config --global user.name "homlex" $ git init $ git add . $ git commit -m "Generate random formulas" $ git remote add origin [email protected]:homlex/Calculator.git $ git push -u origin master
Upload successful
Five & solve problems encountered
Installation on configuration issues: all goes well, no problem.
Code problem: during the same operation, the random numbers generated all the same
Initialize the random seed, will
Random random = new Random();
Changed
Random random = new Random(Guid.NewGuid().GetHashCode());
Code Problem: The results question.
When awakened during the calculation to a specific phase, the data to be used in processing. (I am here is to stack reversed)
Test question: there is no particular problem encountered is the beginning do not know how to write unit tests, but later resolved by Baidu.
git problem: Run
git add
when given as follows:error: open(".vs/Calculator/v15/Server/sqlite3/db.lock"): Permission denied error: unable to index file '.vs/Calculator/v15/Server/sqlite3/db.lock' fatal: adding files failed
The reason: db.lock File Access Denied
Created in the current directory
.gitignore
file, use Notepad to edit:/.vs
Save, again
git add
principle: Since then do not add it to refuse access to it ~Other git problem: specific reference to the article: git first use
end
以上就是本次作业的全过程,掌握了单元测试和性能查看,从性能查看结果可以分析对代码的优化方向。
PS:GitHub是真的慢。:smile: