Created
January 10, 2012 13:50
-
-
Save lyhcode/1589174 to your computer and use it in GitHub Desktop.
sql server load test using groovy
This file contains hidden or 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
@GrabConfig(systemClassLoader=true) | |
@Grab(group='net.sourceforge.jtds', module='jtds', version='1.2.4') | |
import groovy.sql.Sql | |
sql = Sql.newInstance( 'jdbc:jtds:sqlserver://localhost/test', 'sa', | |
'sasasa', 'net.sourceforge.jtds.jdbc.Driver' ) | |
//sql.eachRow( 'select * from test1' ) { println "$it.id -- ${it.rnd} --" } | |
sql.execute('delete from test1'); | |
begin = new Date() | |
for (i = 0; i < 1000000; i++) { | |
random = new Random(new Date().time) | |
sql.execute('insert into test1 (rnd, data) values(?,?)', ["${random.nextInt(199)+100}${random.nextInt(199)+100}${random.nextInt(199)+100}".toString(), new Date().time]) | |
} | |
println(new Date().time - begin.time) | |
sql.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment