

茌成的博客 (AKA joychester) IF you think it is helpful, Take it away for free :)


driver.findElement(By.linkText("Logout")).click();
driver.switchTo().activeElement().sendKeys(Keys.ENTER);
driver.switchTo().alert().accept();
//simulate the mouse hover
Actions builder = new Actions(ldriver);
Action action = builder.moveToElement(sportslink).build();
action.perform();
Hope it helps!
https://docs.google.com/open?id=0B_hz_q1i5QXJTXZqd0FVblAzNms
rem Tested FOR WIN7 OS:
rem set time format:
set hour=%time:~0,2%
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
set min=%time:~3,2%
if "%min:~0,1%" == " " set min=0%min:~1,1%
set secs=%time:~6,2%
if "%secs:~0,1%" == " " set secs=0%secs:~1,1%
rem set date format:
set year=%date:~-8,4%
set month=%date:~0,2%
if "%month:~0,1%" == " " set month=0%month:~1,1%
set day=%date:~3,2%
if "%day:~0,1%" == " " set day=0%day:~1,1%
set datetime=%year%%month%%day%_%hour%%min%%secs%
set GCLOG=-XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:gc-%datetime%.log
The output like this: gc-20120507_172101.log
require 'ruby-prof'
def findprimenumber(uppernumber)
count =0;
for i in 3..uppernumber
primebool = true;
for j in 2...i
if (i%j!=0)
next;
else
primebool = false;
break;
end
end
if(primebool)
count= count+1
end
end
puts("total prime count:#{count}");
puts RubyProf.measure_process_time
end
With optimization:
require 'ruby-prof'
def findprimenumberopt(uppernumber)
count =0;
for i in 3..uppernumber
primebool = true;
if i%2==0
primebool = false;
next;
else
*for j in 3..Math.sqrt(i).floor+1 *
if (i%j!=0)
next;
else
primebool = false;
break;
end
*j=j+2;*
end
end
if(primebool)
count= count+1
end
end
puts("total prime count:#{count}");
puts RubyProf.measure_process_time
end
Given the uppernumber to 100000
The performance result without optimization code :47s
The performance result with optimization code :0.9s
Also you may try more optimization way such as divide and conquer by parallel computing...
def parentmatched(inputstring)
while inputstring != nil
p inputstring
break if (inputstring.gsub!(/\(\)/, '')==nil)
end
if inputstring.eql?('')
puts "matched"
else
puts "non-matched"
end
end
parentmatched("((())(())()(()))()");