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
投稿

猜你喜欢

  • 使用shell检查并修复mysql数据库表的脚本

    2024-01-27 23:52:35
  • PHP递归调用数组值并用其执行指定函数的方法

    2023-09-05 15:35:04
  • php中json 序列化为 [] 的弊端

    2023-05-25 00:14:30
  • sql中case语句的用法浅谈

    2024-01-28 07:52:37
  • 用SQL Server事件探查器创建跟踪

    2009-02-24 17:45:00
  • 实例讲解MySQL中乐观锁和悲观锁

    2024-01-19 00:46:35
  • python 环境搭建 及python-3.4.4的下载和安装过程

    2022-04-24 11:40:44
  • JavaScript实现五子棋游戏的方法详解

    2024-04-30 10:11:54
  • sql server 性能优化之nolock

    2024-01-24 11:34:10
  • python中openpyxl库用法详解

    2023-07-15 09:53:45
  • Python subprocess库六个实例快速掌握

    2021-02-22 05:53:56
  • JS模拟简易滚动条效果代码(附demo源码)

    2024-04-23 09:22:45
  • zabbix通过percona插件监控mysql的方法

    2024-01-23 04:51:22
  • python自动化测试工具Helium使用示例

    2022-09-26 22:59:05
  • display:inline-block的深入理解

    2007-05-11 17:03:00
  • 使用python解析xml成对应的html示例分享

    2022-05-05 21:02:27
  • python apscheduler cron定时任务触发接口自动化巡检过程

    2023-01-04 19:52:50
  • JavaScript使用Range调色及透明度实例

    2024-04-16 10:36:25
  • Jsp+Servlet实现文件上传下载 删除上传文件(三)

    2023-06-27 16:29:29
  • PHP删除数组中空值的方法介绍

    2023-11-24 03:04:19
  • asp之家 网络编程 m.aspxhome.com