<?xml version = "1.0" encoding = "UTF-8" ?> <settings > <client ip = "*.*.*.*" lat = "60.0000" lon = "100.0000" isp = "Samara Telecom, JSC" isprating = "3.3" rating = "5" ispdlavg = "4449" ispulavg = "1394" /> <licensekey > 9c1687ea58e5e770-1df5b7cd427370f7-4b62a84526ea1f56 </licensekey > <customer > speedtest </customer > <servers > <server url = "http://speedtest.pronea.no/speedtest/upload.php" lat = "69.6828" lon = "18.9428" name = "Tromso" country = "Norway" countrycode = "NO" sponsor = "Pronea AS" sponsorurl = "http://www.pronea.no/" id = "1327" gid = "0" bigsamples = "1" /> <server url = "http://test.nax.no/speedtest/upload.php" lat = "65.8333" lon = "13.2000" name = "Helgeland" country = "Norway" countrycode = "NO" sponsor = "Noraxess Broadband" sponsorurl = "http://www.nax.no" id = "1362" gid = "0" url2 = "http://85.221.66.41/speedtest/upload.php" bigsamples = "1" /><?xml version = "1.0" encoding = "UTF-8" ?> <settings > <client ip = "*.*.*.*" lat = "60.0000" lon = "100.0000" isp = "Samara Telecom, JSC" isprating = "3.3" rating = "5" ispdlavg = "4449" ispulavg = "1394" /> <licensekey > 9c1687ea58e5e770-1df5b7cd427370f7-4b62a84526ea1f56 </licensekey > <customer > speedtest </customer > <servers > <server url = "http://speedtest.pronea.no/speedtest/upload.php" lat = "69.6828" lon = "18.9428" name = "Tromso" country = "Norway" countrycode = "NO" sponsor = "Pronea AS" sponsorurl = "http://www.pronea.no/" id = "1327" gid = "0" bigsamples = "1" /> <server url = "http://test.nax.no/speedtest/upload.php" lat = "65.8333" lon = "13.2000" name = "Helgeland" country = "Norway" countrycode = "NO" sponsor = "Noraxess Broadband" sponsorurl = "http://www.nax.no" id = "1362" gid = "0" url2 = "http://85.221.66.41/speedtest/upload.php" bigsamples = "1" /><?xml version = "1.0" encoding = "UTF-8" ?> <settings > <client ip = "*.*.*.*" lat = "60.0000" lon = "100.0000" isp = "Samara Telecom, JSC" isprating = "3.3" rating = "5" ispdlavg = "4449" ispulavg = "1394" /> <licensekey > 9c1687ea58e5e770-1df5b7cd427370f7-4b62a84526ea1f56 </licensekey > <customer > speedtest </customer > <servers > <server url = "http://speedtest.pronea.no/speedtest/upload.php" lat = "69.6828" lon = "18.9428" name = "Tromso" country = "Norway" countrycode = "NO" sponsor = "Pronea AS" sponsorurl = "http://www.pronea.no/" id = "1327" gid = "0" bigsamples = "1" /> <server url = "http://test.nax.no/speedtest/upload.php" lat = "65.8333" lon = "13.2000" name = "Helgeland" country = "Norway" countrycode = "NO" sponsor = "Noraxess Broadband" sponsorurl = "http://www.nax.no" id = "1362" gid = "0" url2 = "http://85.221.66.41/speedtest/upload.php" bigsamples = "1" /><?xml version = "1.0" encoding = "UTF-8" ?> <settings > <client ip = "*.*.*.*" lat = "60.0000" lon = "100.0000" isp = "Samara Telecom, JSC" isprating = "3.3" rating = "5" ispdlavg = "4449" ispulavg = "1394" /> <licensekey > 9c1687ea58e5e770-1df5b7cd427370f7-4b62a84526ea1f56 </licensekey > <customer > speedtest </customer > <servers > <server url = "http://speedtest.pronea.no/speedtest/upload.php" lat = "69.6828" lon = "18.9428" name = "Tromso" country = "Norway" countrycode = "NO" sponsor = "Pronea AS" sponsorurl = "http://www.pronea.no/" id = "1327" gid = "0" bigsamples = "1" /> <server url = "http://test.nax.no/speedtest/upload.php" lat = "65.8333" lon = "13.2000" name = "Helgeland" country = "Norway" countrycode = "NO" sponsor = "Noraxess Broadband" sponsorurl = "http://www.nax.no" id = "1362" gid = "0" url2 = "http://85.221.66.41/speedtest/upload.php" bigsamples = "1" /><?xml version = "1.0" encoding = "UTF-8" ?> <settings > <client ip = "*.*.*.*" lat = "60.0000" lon = "100.0000" isp = "Samara Telecom, JSC" isprating = "3.3" rating = "5" ispdlavg = "4449" ispulavg = "1394" /> <licensekey > 9c1687ea58e5e770-1df5b7cd427370f7-4b62a84526ea1f56 </licensekey > <customer > speedtest </customer > <servers > <server url = "http://speedtest.pronea.no/speedtest/upload.php" lat = "69.6828" lon = "18.9428" name = "Tromso" country = "Norway" countrycode = "NO" sponsor = "Pronea AS" sponsorurl = "http://www.pronea.no/" id = "1327" gid = "0" bigsamples = "1" /> <server url = "http://test.nax.no/speedtest/upload.php" lat = "65.8333" lon = "13.2000" name = "Helgeland" country = "Norway" countrycode = "NO" sponsor = "Noraxess Broadband" sponsorurl = "http://www.nax.no" id = "1362" gid = "0" url2 = "http://85.221.66.41/speedtest/upload.php" bigsamples = "1" /><?xml version = "1.0" encoding = "UTF-8" ?> <settings > <client ip = "*.*.*.*" lat = "60.0000" lon = "100.0000" isp = "Samara Telecom, JSC" isprating = "3.3" rating = "5" ispdlavg = "4449" ispulavg = "1394" /> <licensekey > 9c1687ea58e5e770-1df5b7cd427370f7-4b62a84526ea1f56 </licensekey > <customer > speedtest </customer > <servers > <server url = "http://speedtest.pronea.no/speedtest/upload.php" lat = "69.6828" lon = "18.9428" name = "Tromso" country = "Norway" countrycode = "NO" sponsor = "Pronea AS" sponsorurl = "http://www.pronea.no/" id = "1327" gid = "0" bigsamples = "1" /> <server url = "http://test.nax.no/speedtest/upload.php" lat = "65.8333" lon = "13.2000" name = "Helgeland" country = "Norway" countrycode = "NO" sponsor = "Noraxess Broadband" sponsorurl = "http://www.nax.no" id = "1362" gid = "0" url2 = "http://85.221.66.41/speedtest/upload.php" bigsamples = "1" /><?xml version = "1.0" encoding = "UTF-8" ?> <settings > <client ip = "*.*.*.*" lat = "60.0000" lon = "100.0000" isp = "Samara Telecom, JSC" isprating = "3.3" rating = "5" ispdlavg = "4449" ispulavg = "1394" /> <licensekey > 9c1687ea58e5e770-1df5b7cd427370f7-4b62a84526ea1f56 </licensekey > <customer > speedtest </customer > <servers > <server url = "http://speedtest.pronea.no/speedtest/upload.php" lat = "69.6828" lon = "18.9428" name = "Tromso" country = "Norway" countrycode = "NO" sponsor = "Pronea AS" sponsorurl = "http://www.pronea.no/" id = "1327" gid = "0" bigsamples = "1" /> <server url = "http://test.nax.no/speedtest/upload.php" lat = "65.8333" lon = "13.2000" name = "Helgeland" country = "Norway" countrycode = "NO" sponsor = "Noraxess Broadband" sponsorurl = "http://www.nax.no" id = "1362" gid = "0" url2 = "http://85.221.66.41/speedtest/upload.php" bigsamples = "1" />
<?xml version = "1.0" encoding = "UTF-8" ?> <settings > <client ip = "*.*.*.*" lat = "60.0000" lon = "100.0000" isp = "Samara Telecom, JSC" isprating = "3.3" rating = "5" ispdlavg = "4449" ispulavg = "1394" /> <licensekey > 9c1687ea58e5e770-1df5b7cd427370f7-4b62a84526ea1f56 </licensekey > <customer > speedtest </customer > <servers > <server url = "http://speedtest.pronea.no/speedtest/upload.php" lat = "69.6828" lon = "18.9428" name = "Tromso" country = "Norway" countrycode = "NO" sponsor = "Pronea AS" sponsorurl = "http://www.pronea.no/" id = "1327" gid = "0" bigsamples = "1" /> <server url = "http://test.nax.no/speedtest/upload.php" lat = "65.8333" lon = "13.2000" name = "Helgeland" country = "Norway" countrycode = "NO" sponsor = "Noraxess Broadband" sponsorurl = "http://www.nax.no" id = "1362" gid = "0" url2 = "http://85.221.66.41/speedtest/upload.php" bigsamples = "1" />
void _getConfig ( ){std :: stringstream netspeedConfigStream = _sendPacket ( _SpeedtestServer、_SpeedtestConfigUrl ) ;//空のプロパティツリーオブジェクトを作成しますboost :: property_tree :: ptreeを使用し ます。ptree PropertyTree ;// XMLファイルを読み込み、その内容をプロパティツリーに配置します。// Koenigのため、名前空間の修飾は必要ありません// 2番目の引数を検索します。 読み取りに失敗した場合、例外//スローされます。read_xml ( netspeedConfigStream、PropertyTree ) ;ptree設定= PropertyTree。 get_child ( "settings" ) ;//クライアントの場所を構築します_ServerLocation * _ClientLocation ;//サーバーの場所のリストを宣言しますstd :: vector < _ServerLocation > * _ServerLocationList ;_ClientLocation = new _ServerLocation ( Settings。Begin ( ) - > second、 false ) ;_ServerLocationList = new std :: vector < _ServerLocation > ;// XMLからリストを構築しますBOOST_FOREACH ( ptree :: value_type & v、PropertyTree。Get_child ( "settings.servers" ) )_ServerLocationList- > push_back ( _ServerLocation ( v。Second、 true ) ) ;std :: sort ( _ServerLocationList- > begin ( ) 、_ ServerLocationList- > end ( ) 、_ ServerLocationSortFunctor ( _ClientLocation ) )) ;//最も近いサーバーのURLstd :: vector < std :: string > SplitUrl ;boost :: split ( SplitUrl、_ServerLocationList- > begin ( ) - > GetUrl ( ) 、boost :: is_any_of ( "/" ) ) ;_ClientLocationを削除します。_ServerLocationListを削除します。_NearestServer = SplitUrl [ 2 ] ;for ( int i = 3 ; i < SplitUrl。size ( ) - 1 ; ++ i ) // TODO:イテレータで書き換える{_NearestServerUrl。 追加 ( "/" ) ;_NearestServerUrl。 append ( SplitUrl [ i ] ) ;}帰る}
struct _ServerLocationSortFunctor{公開 :_ServerLocationSortFunctor ( _ServerLocation * ClientLocation ) : _ClientLocation ( ClientLocation ) { }bool演算子( ) ( _ServerLocation & _First、_ServerLocation & _Second ){return _ServerDist ( _ClientLocation、 & _First ) < _ServerDist ( _ClientLocation、 & _Second ) ;}プライベート :_ServerLocation * _ClientLocation ;インライン double deg2rad ( double ServerAplpha ){ServerAplpha * PI / 180を 返し ます。}インライン 二重 hypot3 ( 二重 dx、 二重 dy、 二重 dz ){return sqrt ( dx * dx + dy * dy + dz * dz ) ;}double _ServerDist ( _ServerLocation * _First、_ServerLocation * _Second ){double phi1 = deg2rad ( _First- > GetLon ( ) ) ;double psi1 = deg2rad ( _First- > GetLat ( ) ) ;double phi2 = deg2rad ( _Second- > GetLon ( ) ) ;double psi2 = deg2rad ( _Second- > GetLat ( ) ) ;double cos_psi1 = cos ( psi1 ) ;double x1 = EarthRadius * cos ( phi1 ) * cos_psi1 ;double y1 = EarthRadius * sin ( phi1 ) * cos_psi1 ;double z1 = EarthRadius * sin ( psi1 ) ;double cos_psi2 = cos ( psi2 ) ;double x2 = EarthRadius * cos ( phi2 ) * cos_psi2 ;double y2 = EarthRadius * sin ( phi2 ) * cos_psi2 ;double z2 = EarthRadius * sin ( psi2 ) ;double d = hypot3 ( x2 - x1、y2 - y1、z2 - z1 ) ;EarthRadius * acos ( 1- ( d * d ) / ( 2 * EarthRadius * EarthRadius ) ) ;}} ;
void _testLatency ( ){std :: string Url ( _NearestServerUrl ) ;URL append ( _LatencyUrl ) ;boost :: タイマー LatencyTimer ;_sendPacket ( _NearestServer、Url ) ;_LatencyTime = LatencyTimer。 経過 ( ) ;std :: cout << "PING:" << _LatencyTime << std :: endl ;帰る}void _testDownload ( ){std :: string Url ( _NearestServerUrl ) ;URL append ( _DownloadUrl ) ;boost :: タイマー DownloadTimer ;std :: stringstream DownloadPacket = _sendPacket ( _NearestServer、Url ) ;double DownloadTime = DownloadTimer。 経過 ( ) ;double DownloadSpeed = ( DownloadPacket.str ( ) 。 length ( ) / ( DownloadTime - _LatencyTime ) )) * 8/1024 ;std :: cout << "DOWNLOAD:" << DownloadSpeed << std :: endl ;帰る}void _testUpload ( ){std :: string Url ( _NearestServerUrl ) ;URL append ( _UploadUrl ) ;std :: string UploadDataValue ( _UploadBytes、 'a' ) ;std :: string UploadData ( "content0 =" ) ;UploadData + = UploadDataValue ;boost :: タイマー UploadTimer ;_sendPacket ( _NearestServer、Url、 true 、UploadData ) ;double UploadTime = UploadTimer。 経過 ( ) ;double UploadSpeed = ( _UploadBytes / ( UploadTime - _LatencyTime ) ) * 8/1024 ;std :: cout << "UPLOAD:" << UploadSpeed << std :: endl ;}
Source: https://habr.com/ru/post/J93916/More articles:別のサイトからのMODxおよびパーサープレートGoogleがGIPS VoIPエンジンを購入するのはなぜですか?Googleカレンダーの更新ChronoPayディレクターの秘密の生活Flash Player Lightsparkの最初のベータ版自分でそれを行う、またはfork()またはforkしない()Yandex.comボーイングを置き換えるために設計されたMITトランスフォーマーゲームプログラマーズノート:OOP、And、およびOrAll Articles