--print '数据库写性能测试...'
set nocount on
use hswinrun2
go
if not exists(select 1 from hswinrun2..sysobjects where name = 'testcontrol')
begin
create table testcontrol(status1 int)
insert testcontrol values(0)
end
go
if exists(select 1 from hswinrun2..sysobjects where name = 'testaa')
drop table testaa
go
create table testaa (i1 int, c2 char(200))
create index idx_testaa on testaa (i1)
go
truncate table testaa
go
Declare @ii int,
@s_time datetime,
@e_time datetime,
@e_time_x datetime,
@e_time_r datetime,
@iMax bigint
set @iMax=10000
select @ii = 1
while exists(select 1 from testcontrol where status1 = 1)
begin
select @ii = 1
end
select @s_time = getdate()
While @ii <= @iMax
Begin
Insert testaa values(@ii, 'adkdkddkfjslfjasdfja')
Select @ii = @ii + 1
End
select @e_time = getdate()
select '插入耗时' + convert(varchar, datediff(ms, @s_time, @e_time)) + '毫秒'
--drop table testaa
--print '数据库索引性能测试...
select @ii=@iMax
while @ii>=(@iMax-50)
begin
select * from testaa where i1=@ii
select @ii=@ii-1
end
select @e_time_x = getdate()
select '索引耗时' + convert(varchar, datediff(ms, @e_time, @e_time_x)) + '毫秒'
--print '测试大量数据读取性能...'
select * from testaa
select @e_time_r = getdate()
select '读取耗时' + convert(varchar, datediff(ms, @e_time_x, @e_time_r)) + '毫秒'
drop table testaa
回复 更多评论