asp如何计算下载一个文件需要多长时间?

来源:asp之家 时间:2009-11-25 20:17:00 

我们用下了asp代码简单统计了下载一个文件需要的时间:

<%
Function DownloadTime(intFileSize, strModemType)
Dim TimeInSeconds, ModemSpeed, strDownloadTime, AppendString
Dim intYears, intWeeks, intDays
Dim intHours, intMinutes, intSeconds
intYears = 0
intWeeks = 0
intDays = 0
intHours = 0
intMinutes = 0
intSeconds = 0
strDownloadTime = ""
Select Case strModemType
Case "Cable"
  ModemSpeed = 400000
Case "56kbps"
  ModemSpeed = 7000
Case "33.6kbps"
  ModemSpeed = 4200
Case "28.8kbps"
  ModemSpeed = 3600
End Select
TimeInSeconds = int(intFileSize / ModemSpeed)
' 准确地说,1年=365.25天
If (Int(TimeInSeconds / 31471200) <> 0) Then intYears = Int(TimeInSeconds / 31449600)
If ((Int(TimeInSeconds / 604800) Mod 52) <> 0) Then intWeeks = Int(TimeInSeconds / 604800) Mod 52
If ((Int(TimeInSeconds / 86400) Mod 7) <> 0) Then intDays = Int(TimeInSeconds / 86400) Mod 7
If TimeInSeconds >= 3600 Then intHours = Int(TimeInSeconds / 3600) Mod 24
If TimeInSeconds >= 60 Then intMinutes = Int(TimeInSeconds / 60) Mod 60
If TimeInSeconds >= 0 Then intSeconds = Int(TimeInSeconds) Mod 60
If intYears <> 0 Then
  strDownloadTime = strDownloadTime & intYears & "年" & AppendString & ", "
End If
If intWeeks <> 0 Then
  strDownloadTime = strDownloadTime & intWeeks & "周" & AppendString & ", "
End If
If intDays <> 0 Then
  strDownloadTime = strDownloadTime & intDays & "日" & AppendString & ", "
End If
If intHours <> 0 Then
  strDownloadTime = strDownloadTime & intHours & "小时" & AppendString & ", "
End If
If intMinutes <> 0 Then
  strDownloadTime = strDownloadTime & intMinutes & "分" & AppendString
End If
If ((intYears = 0) And (intWeeks = 0) And (intDays = 0) And (intHours = 0)) Then
  If intMinutes > 0 Then
  strDownloadTime = strDownloadTime  & ", " & intSeconds & "秒" & AppendString
  Else
  strDownloadTime = strDownloadTime & intSeconds & "秒" & AppendString
  End If
End If
DownloadTime = strDownloadTime
End Function
%>
<html>
<body>
asp之家提示:您下载这个文件一共花费了<%=DownloadTime(123456,Cable)%>.
</body>
</html>

标签:下载,时间,统计,asp
0
投稿

猜你喜欢

  • 什么样的分页案例才是好的

    2007-11-23 19:08:00
  • 实例:arguments.callee的应用

    2009-04-20 12:38:00
  • 前端来看看 maxthon bugs

    2008-09-23 18:35:00
  • ajax 同步请求和异步请求的差异分析

    2011-07-05 12:36:04
  • asp经典入门教程 在ASP中使用SQL 语句

    2013-06-01 20:23:21
  • ASP伪静态页简单教程

    2007-09-28 14:35:00
  • YUI3设计中的激进和妥协

    2010-01-17 09:59:00
  • 全面了解CSS内置颜色(color)值

    2008-11-19 12:26:00
  • 文字的减法

    2007-11-06 12:58:00
  • 使用XMLhttp生成html页面

    2007-08-17 11:21:00
  • Oracle 中文字段进行排序的sql语句

    2009-09-26 18:58:00
  • 网页视频播放器程序代码(通用代码),支持avi,wmv,asf,mov,rm,ra,ram等

    2008-07-16 11:56:00
  • 揭秘SQL Server 2008性能和可扩展性

    2009-03-10 14:47:00
  • 将ASP记录集输出成n列的表格形式显示的方法

    2011-04-08 10:51:00
  • 用JS访问操作iframe框架里的dom

    2008-11-10 13:05:00
  • 记Qzone项目组视觉设计标注的前前后后

    2010-03-24 18:03:00
  • Dreamweaver MX 2004新特点

    2008-02-03 11:35:00
  • 如何选择合适的MySQL存储引擎

    2009-02-04 13:02:00
  • ASP 递归调用 已知节点查找根节点的函数

    2011-03-08 10:48:00
  • 设计中基于人类学的田野调查与比较研究法 ——浅谈用研与竞品分析方法之理论基础

    2009-08-31 16:45:00
  • asp之家 网络编程 m.aspxhome.com