Zend API中文文档
- 格式:pdf
- 大小:487.85 KB
- 文档页数:57
Package‘zoltr’October14,2022Title Interface to the'Zoltar'Forecast Repository APIVersion0.5.1Description'Zoltar'<https:///>is a website that provides a repository of model forecast resultsin a standardized format and a central location.It supports storing,retrieving,comparing,and an-alyzing timeseries forecasts for prediction challenges of interest to the modeling community.This pack-age provides functionsfor working with the'Zoltar'API,including connecting and authenticating,getting informa-tion about projects,models,and forecasts,deleting and uploading forecast data,and downloading scores.URL https:///reichlab/zoltr,http://reichlab.io/zoltr/BugReports https:///reichlab/zoltr/issuesLicense GPL-3Encoding UTF-8LazyData trueSuggests testthat,knitr,rmarkdownImports httr,jsonlite,readr,mockery,webmockr,base64url,dplyr,MMWRweek,utils,rlang,magrittrRoxygenNote7.1.0VignetteBuilder knitrNeedsCompilation noAuthor Matthew Cornell[aut,cre],Nicholas Reich[aut,cph]Maintainer Matthew Cornell<*****************>Repository CRANDate/Publication2020-04-1500:20:03UTC12create_model R topics documented:create_model (2)create_project (3)delete_forecast (4)delete_model (4)delete_project (5)download_forecast (6)forecasts (6)forecast_data_from_cdc_csv_file (7)forecast_data_from_cdc_data_frame (8)forecast_info (8)get_resource (9)models (9)model_info (10)new_connection (11)projects (11)project_info (12)scores (13)targets (13)target_info (14)timezeros (15)timezero_info (15)truth (16)unit_info (17)upload_forecast (17)upload_info (18)upload_info_forecast_url (19)zoltar_authenticate (20)zoltar_units (20)Index22 create_model Create a modelDescriptionCreates the model in the passed project using the passed list.Fails if a model with the passed name already exists.Usagecreate_model(zoltar_connection,project_url,model_config)create_project3Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection project_url url of a project in zoltar_connection’s projects.this is the project the new model will be created inmodel_config A‘list‘containing a Zoltar model configuration.An example:example-model-config.json.Full documentation at https:///.Valuemodel_url of the newly-created modelExamples##Not run:new_model_url<-create_model(conn,"https:///project/9/",jsonlite::read_json("example-model-config.json"))##End(Not run)create_project Create a projectDescriptionCreates the project using the passed project configuration list.Fails if a project with the passed name already exists.Usagecreate_project(zoltar_connection,project_config)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection project_config A‘list‘containing a Zoltar project configuration.note that this list validated by the server and not here.An example:cdc-project.json Full documentation athttps:///.Valueproject_url of the newly-created project4delete_modelExamples##Not run:new_project_url<-create_project(conn,jsonlite::read_json("cdc-project.json"))##End(Not run)delete_forecast Delete a forecastDescriptionDeletes the forecast with the passed URL.This is permanent and cannot be undone.Usagedelete_forecast(zoltar_connection,forecast_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection forecast_url URL of a forecast in zoltar_connection’s forecastsValueNoneExamples##Not run:delete_forecast(conn,"/api/forecast/1/")##End(Not run)delete_model Delete a modelDescriptionDeletes the model with the passed ID.This is permanent and cannot be undone.Usagedelete_model(zoltar_connection,model_url)delete_project5Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection model_url URL of a model in zoltar_connection’s modelsValueNoneExamples##Not run:delete_model(conn,"/api/model/1/")##End(Not run)delete_project Delete a projectDescriptionDeletes the project with the passed URL.This is permanent and cannot be undone.Usagedelete_project(zoltar_connection,project_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection project_url URL of a project in zoltar_connection’s projectsValueNoneExamples##Not run:delete_project(conn,"https:///project/9/")##End(Not run)6forecasts download_forecast Gets a forecast’s dataDescriptionGets a forecast’s dataUsagedownload_forecast(zoltar_connection,forecast_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection forecast_url URL of a forecast in zoltar_connection’s forecastsValueForecast data as a‘list‘in the Zoltar standard format.meta information is ignored.Full documen-tation at https:///.Examples##Not run:forecast_data<-download_forecast(conn,"/api/forecast/1/")##End(Not run)forecasts Get a model’s forecastsDescriptionGet a model’s forecastsUsageforecasts(zoltar_connection,model_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection model_url URL of a model in zoltar_connection’s modelsforecast_data_from_cdc_csv_file7 ValueA‘data.frame‘of forecast information for the passed modelExamples##Not run:the_forecasts<-forecasts(conn,"/api/model/1/")##End(Not run)forecast_data_from_cdc_csv_fileLoads and converts a CDC CSVfile to Zoltar’s native‘list‘formatDescriptionLoads and converts a CDC CSVfile to Zoltar’s native‘list‘formatUsageforecast_data_from_cdc_csv_file(season_start_year,cdc_csv_file)Argumentsseason_start_yearAn integer specifying the"season"that cdc_csv_file is ed to convert EWsto YYYY_MM_DD_DATE_FORMAT.zoltr uses week30as the season break-point,e.g.the"2016/2017season"starts withcdc_csv_file A CDC CSVfileValuecdc_csv_file’s data as Zoltar’s native‘list‘format,but only the"predictions"item,and not"meta"Examples##Not run:forecast_data<-forecast_data_from_cdc_csv_file(2016,"my_forecast.cdc.csv")##End(Not run)8forecast_infoforecast_data_from_cdc_data_frame‘forecast_data_from_cdc_csv_file()‘helperDescription‘forecast_data_from_cdc_csv_file()‘helperUsageforecast_data_from_cdc_data_frame(season_start_year,cdc_data_frame)Argumentsseason_start_yearas passed to‘forecast_data_from_cdc_csv_file()‘cdc_data_frame""Valuesame as‘forecast_data_from_cdc_csv_file()‘forecast_info Gets a forecast’s informationDescriptionGets a forecast’s informationUsageforecast_info(zoltar_connection,forecast_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection forecast_url URL of a forecast in zoltar_connection’s forecastsValueA‘list‘of forecast information for the passed forecast_urlget_resource9Examples##Not run:the_forecast_info<-forecast_info(conn,"/api/forecast/1/")##End(Not run)get_resource Get JSON for a resource(URL).Authenticates if necessaryDescriptionGet JSON for a resource(URL).Authenticates if necessaryUsageget_resource(zoltar_connection,url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection url A string of the resource’s URLValueA‘list‘that contiains JSON information for the passed URLmodels Get a project’s modelsDescriptionGet a project’s modelsUsagemodels(zoltar_connection,project_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection project_url URL of a project in zoltar_connection’s projects10model_info ValueA‘data.frame‘of model contents for all models in the passed projectExamples##Not run:the_models<-models(conn,"https:///project/9/")##End(Not run)model_info Get information about a modelDescriptionGet information about a modelUsagemodel_info(zoltar_connection,model_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection model_url URL of a model in zoltar_connection’s modelsValueA‘list‘of model information for the passed model_urlExamples##Not run:the_model_info<-model_info(conn,"/api/model/1/")##End(Not run)new_connection11 new_connection Get a connection to a Zoltar hostDescriptionReturns a new connection object,which is the starting point for working with the Zoltar API.Once you have the connection you can call zoltar_authenticate on it,and then call projects to get a list of Project objects to start working with.Usagenew_connection(host="https://")Argumentshost The Zoltar site to connect to.Does*not*include a trailing slash(’/’).Defaults to https://DetailsA note on URLs:We require a trailing slash(’/’)on all URLs.The only exception is the hostarg passed to this function.This convention matches Django REST framework one,which is what Zoltar is written in.ValueA‘ZoltarConnection‘objectExamples##Not run:conn<-new_connection()##End(Not run)projects Get information about all projectsDescriptionGet information about all projectsUsageprojects(zoltar_connection)12project_infoArgumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connectionValueA‘data.frame‘of all projects’contentsExamples##Not run:the_projects<-projects(conn)##End(Not run)project_info Get information about a projectDescriptionGet information about a projectUsageproject_info(zoltar_connection,project_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection project_url URL of a project in zoltar_connection’s projectsValueA‘list‘of project information for the passed project_urlExamples##Not run:the_project_info<-project_info(conn,"https:///project/9/")##End(Not run)scores13 scores Get a project’s scoresDescriptionGet a project’s scoresUsagescores(zoltar_connection,project_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection project_url URL of a project in zoltar_connection’s projectsValueA‘data.frame‘of score data for all models in the passed project URLExamples##Not run:the_scores<-scores(conn,"https:///project/9/")##End(Not run)targets Get a project’s targetsDescriptionGet a project’s targetsUsagetargets(zoltar_connection,project_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection project_url URL of a project in zoltar_connection’s projects14target_info ValueA‘data.frame‘of target contents for the passed projectExamples##Not run:the_targets<-targets(conn,"https:///project/9/")##End(Not run)target_info Get information about a targetDescriptionGet information about a targetUsagetarget_info(zoltar_connection,target_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection target_url URL of a target in zoltar_connection’s targetsValueA‘list‘of target information for the passed target_urlExamples##Not run:the_target_info<-target_info(conn,"https:///target/3/")##End(Not run)timezeros15 timezeros Get a project’s timezerosDescriptionGet a project’s timezerosUsagetimezeros(zoltar_connection,project_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection project_url URL of a project in zoltar_connection’s projectsValueA‘data.frame‘of timezero contents for the passed projectExamples##Not run:the_timezeros<-timezeros(conn,"https:///project/9/")##End(Not run)timezero_info Get information about a timezeroDescriptionGet information about a timezeroUsagetimezero_info(zoltar_connection,timezero_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection timezero_url URL of a timezero in zoltar_connection’s timezeros16truth ValueA‘list‘of timezero information for the passed timezero_urlExamples##Not run:the_timezero_info<-timezero_info(conn,"https:///timezero/3/") ##End(Not run)truth Get a project’s truthDescriptionGet a project’s truthUsagetruth(zoltar_connection,project_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection project_url URL of a project in zoltar_connection’s projectsValueA‘data.frame‘of truth data for the passed project URLExamples##Not run:the_truth<-truth(conn,"https:///project/9/")##End(Not run)unit_info17 unit_info Get information about a unitDescriptionGet information about a unitUsageunit_info(zoltar_connection,unit_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection unit_url URL of a unit in zoltar_connection’s zoltar_unitsValueA‘list‘of unit information for the passed unit_urlExamples##Not run:the_unit_info<-unit_info(conn,"https:///unit/3/")##End(Not run)upload_forecast Upload a forecastDescriptionThis function submits forecast data to the server for uploading.Returns an UploadFileJob object that can be used to up,which depends on the number of current uploads in the queue.Zoltar tracks these via‘UploadFileJob‘objects.)Usageupload_forecast(zoltar_connection,model_url,timezero_date,forecast_data,notes="")18upload_infoArgumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection model_url URL of a model in zoltar_connection’s projectstimezero_date The date of the project timezero you are uploading for.it is a string in format YYYYMMDDforecast_data Forecast data as a‘list‘in the Zoltar standard formatnotes Optional user notes for the new forecastValueAn UploadFileJob URL for the uploadExamples##Not run:forecast_data<-jsonlite::read_json("docs-predictions.json")upload_file_job_url<-upload_forecast(conn,"/api/model/1/","2017-01-17",forecast_data,"a mid-January forecast") ##End(Not run)upload_info Get an upload’s informationDescriptionGets an upload’s information that can be used to track the upload’s progress.(Uploads are processed in a queue,Usageupload_info(zoltar_connection,upload_file_job_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection upload_file_job_urlURL of a job in zoltar_connection that was uploaded via upload_forecastValueA‘list‘of upload information for the passed upload_file_job_url.it has these names:id,url,status, user,created_at,updated_at,failure_message,filename,input_json,output_jsonupload_info_forecast_url19 Examples##Not run:the_upload_info<-upload_info(conn,"/api/uploadfilejob/2/")##End(Not run)upload_info_forecast_urlGet a new forecast upload’s urlDescriptionA helper function that returns the URL of a newly-uploaded forecast from upload_info.Usageupload_info_forecast_url(zoltar_connection,the_upload_info)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connectionthe_upload_infoa‘list‘object as returned by upload_infoValueA URL of the new forecastExamples##Not run:new_forecast_url<-upload_info_forecast_url(conn,"/api/uploadfilejob/2/") ##End(Not run)20zoltar_units zoltar_authenticate Log in to a Zoltar hostDescriptionReturns a new‘ZoltarConnection‘object,which is the starting point for working with the Zoltar API.Once you have the connection you can call zoltar_authenticate()on it,and call projects()to get a list of objects to start working with.Usagezoltar_authenticate(zoltar_connection,username,password)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection.username Username for the account to use on the connection’s hostpassword Password""ValueNoneExamples##Not run:zoltar_authenticate(conn,"USERNAME","PASSWORD")##End(Not run)zoltar_units Get a project’s zoltar_unitsDescriptionGet a project’s zoltar_unitsUsagezoltar_units(zoltar_connection,project_url)Argumentszoltar_connectionA‘ZoltarConnection‘object as returned by new_connection project_url URL of a project in zoltar_connection’s projectszoltar_units21ValueA‘data.frame‘of unit contents for the passed projectExamples##Not run:the_units<-zoltar_units(conn,"https:///project/9/")##End(Not run)Indexcreate_model,2create_project,3delete_forecast,4delete_model,4delete_project,5download_forecast,6forecast_data_from_cdc_csv_file,7forecast_data_from_cdc_data_frame,8 forecast_info,8forecasts,6get_resource,9model_info,10models,9new_connection,3–6,8–10,11,12–20project_info,12projects,11,11scores,13target_info,14targets,13timezero_info,15timezeros,15truth,16unit_info,17upload_forecast,17,18upload_info,18,19upload_info_forecast_url,19zoltar_authenticate,11,20zoltar_units,2022。
API接口文档(快速版)概述本文档提供了关于API接口的快速参考指南,旨在帮助开发人员快速了解接口的功能和使用方法。
接口列表本文档涵盖以下API接口:... (根据实际情况继续列出其他接口)接口1:接口名称接口描述这个接口用于...请求请求类型- 请求方法:POST- 请求路径:/api/endpoint请求参数请求示例POST /api/endpoint {"param1": "value1", "param2": 123}响应响应参数响应示例{"param1": "value1", "param2": 123, ...}错误情况接口2:接口名称接口描述这个接口用于...请求请求类型- 请求方法:GET- 请求路径:/api/endpoint/{param} 请求参数请求示例GET /api/endpoint/abc123响应响应参数响应示例{"param1": "value1","param2": 123,...}错误情况接口3:接口名称接口描述这个接口用于...请求请求类型- 请求方法:PUT- 请求路径:/api/endpoint/{id} 请求参数请求示例PUT /api/endpoint/123 {"param1": "value1", ...}响应响应参数响应示例{"param1": "value1", "param2": 123,...}错误情况请根据实际情况修改接口的描述、请求参数、响应参数和错误情况等内容,并补充完整其他接口的信息。
以上仅为示例,不代表实际接口。
Package‘zdeskR’May2,2023Title Connect to Your'Zendesk'DataVersion0.3.0Description Facilitates making a connection to the'Zendesk'API and executing various queries.You can use it toget ticket,ticket metrics,and user data.The'Zendesk'documentation isavailable at<https:///rest_api/docs/support/introduction>.This package is not supported by'Zendesk'(owner of the software).URL https:///chrisumphlett/zdeskRBugReports https:///chrisumphlett/zdeskR/issuesLicense CC0Encoding UTF-8Imports dplyr(>=1.0.0),magrittr(>=1.5),jsonlite(>=1.6.1),purrr(>=0.3.3),httr(>=1.4.1),tidyr(>=1.0.0),plyr(>=1.8.6)RoxygenNote7.1.2NeedsCompilation noAuthor Chris Umphlett[aut,cre],Avinash Panigrahi[aut]Maintainer Chris Umphlett<******************************>Repository CRANDate/Publication2023-05-0212:40:02UTCR topics documented:get_all_ticket_metrics (2)get_custom_fields (3)get_tickets (4)get_users (5)Index712get_all_ticket_metricsget_all_ticket_metricsGet Metrics on All Zendesk TicketsDescriptionThis function takes your Email Id,authentication token,sub-domain and parse all the tickets and its corresponding metrics in a list.Since each iteration only returns100tickets at a time you must run the loop until the"next_page"parameter is equal to null.Usageget_all_ticket_metrics(email_id,token,subdomain)Argumentsemail_id Zendesk Email Id(username).token Zendesk API token.subdomain Your organization’s Zendesk sub-domain.DetailsIts not a good practice to write down these authentication parameters in your code.There are various methods and packages available that are more secure;this package doesn’t require you to use any one in particular.ValueData Frame with metrics for all ticketsReferenceshttps:///rest_api/docs/support/ticket_metricsExamples##Not run:ticket_metrics<-get_all_ticket_metrics(email_id,token,subdomain)##End(Not run)get_custom_fields3 get_custom_fields Returns the system and all the customfields defined by your organiza-tion’s zendesk administratorDescriptionIt takes your Email Id,authentication token,sub-domain as parameters and gets the system and all the customfields available for a zendesk ticket.Usageget_custom_fields(email_id,token,subdomain)Argumentsemail_id Zendesk Email Id(username).token Zendesk API token.subdomain Your organization’s Zendesk sub-domain.DetailsIt’s not a good practice to write down these authentication parameters in your code.There are various methods and packages available that are more secure;this package doesn’t require you to use any one in particular.ValueA data frame containing all ticketfieldsReferenceshttps:///rest_api/docs/support/ticket_fieldsExamples##Not run:fields<-get_custom_fields(email_id,token,subdomain)##End(Not run)4get_tickets get_tickets Get Zendesk TicketsDescriptionThis function takes your Email Id,authentication token,sub-domain and start time as parameters and gets all the tickets which have been updated on or after the start time parameter.By default each page returns1000unique tickets and an"after_cursor"value which stores a pointer to the next page.After getting thefirst page it uses the pointer to fetch the subsequent pages.Usageget_tickets(email_id,token,subdomain,start_time,remove_cols=NULL) Argumentsemail_id Zendesk Email Id(username).token Zendesk API token.subdomain Your organization’s Zendesk sub-domain.start_time String with a date or datetime to get all tickets modified after that date.remove_cols Vector of column names to remove from the results.DetailsThe start time parameter should be in’UTC’format as Zendesk uses the’UTC’time zone when retrieving tickets after the start time.For example,the US Eastern Time Zone is currently four hours being UTC.If one wanted to get tickets starting on August1at12am,you would need to enter"2020-08-0104:00:00".The user must do proper adjustment to accommodate the time zone difference,if desired.A date can be provided,it will retrieve results as of12am in the UTC time zone.Start and end times can be entered with or without the time component.End time cannot be in the future,but should work for values up to one minute prior to the current time.It’s not a good practice to write down these authentication parameters in your code.There are various methods and packages available that are more secure;this package doesn’t require you to use any one in particular.The remove_cols parameter allows the removal of customfields causing errors.Errors occurred when afield was sometimes blank and assigned a logical type and then appended to non-blank, non-logical inside of purrr::map_dfr.See issue#1on GH.Valuea Data Frame containing all tickets after the start time.Referenceshttps:///rest_api/docs/support/incremental_export#start_timeExamples##Not run:all_tickets<-get_tickets(email_id,token,subdomain,start_time="2021-01-3100:00:00",end_time="2021-01-3123:59:59")##End(Not run)get_users Returns All Available Zendesk Users.DescriptionIt takes your Email Id,authentication token,sub-domain and parse all the users in a list.It iterates through all the pages returning only100users per page until the"next_page"parameter becomes null indicating there are no more pages to fetch.Usageget_users(email_id,token,subdomain,start_time,user_role="all")Argumentsemail_id Zendesk Email Id(username).token Zendesk API token.subdomain Your organization’s Zendesk sub-domain.start_time String with a date or datetime to get all tickets modified after that date.user_role User role,one of"all","end-user","agent",or"admin".DetailsIt’s not a good practice to write down these authentication parameters in your code.There are various methods and packages available that are more secure;this package doesn’t require you to use any one in particular.The start_page parameter is useful if you have many users.Each page contains100users.Zendesk does not have an incremental method for pulling users by date but after you retrieve all of your users once,you can then increment your start page to something that will limit the number of users you are re-pulling each time.If you are pulling partial lists of users be aware that you will not get updates on older users.You will only get recently created users,not modified/deleted users and their modified data nor updated last login dates.ValueData Frame with user detailsReferenceshttps:///rest_api/docs/support/usersExamples##Not run:users<-get_users(email_id,token,subdomain)##End(Not run)Indexget_all_ticket_metrics,2get_custom_fields,3get_tickets,4get_users,57。
禅道使用手册1、安装禅道为了简化大家在windows下面的安装,我们在xampp基础上做了禅道的windows 一键安装包。
xampp是业内非常著名的AMP集成运行环境。
禅道的一键安装包主要在它基础上做了大量的精简,并集成了我们自主开发的集成面板,使用起来会更加方便。
关于xampp一键安装包,大家有兴趣可以访问下面的官方网站: https:/// (注:这个是xampp官方网站,禅道一键安装包不需要登录这个网址下载)。
禅道9.2.stable版本升级了Windows一键安装包。
禅道运行集成面板升级到2.0.0版本,我们有针对64位和32位分别打包,请根据自己的电脑下载对应的Windows一键安装包。
启用Apache用户验证,修改mysql密码的功能,新安装时会提示安装VC环境。
注:windows一键安装包中已经集成了XXD服务,不需要再单独安装部署XXD。
一、Windows 64/32位一键安装包的安装1、运行Windows一键安装包在我们的站点下载新的windows集成运行环境(.exe结尾)。
双击解压缩到某一个分区的根目录,比如c:\xampp,或者d:\xampp,必须是根目录。
进入xampp文件夹,点击start.exe启动禅道时,如果电脑没有安装过VC运行环境时,会提示安装VC++环境。
•如果不想开启访问验证功能,可以把集成面板最后一行左侧的对号去掉。
•启用访问验证后,用户需要先输入集成面板最后一行的帐号密码(此帐号密码需要提供给所有禅道登录人员)才可以访问到禅道登录页面(登录页面需要输入禅道的登录帐号方可登录,默认登录禅道帐号:admin 密码:1123456)。
•如果需要修改Apache用户访问验证的账号和密码,可以在运行集成面板最后一行的“更改”按钮进行修改。
4、超级管理员登录密码修改即可进入禅道数据库登录页面。
在登录页面填写xampp/zentao/config/my.php里的对应参数,即可进入禅道数据库。
Advanced Micro DevicesZenDNN User Guide Publication #57300Revision #4.0Issue Date January 2023© 2023 Advanced Micro Devices Inc. All rights reserved.The information contained herein is for informational purposes only, and is subject to change without notice. While every precaution has been taken in the preparation of this document, it may contain technical inaccuracies, omissions and typographical errors, and AMD is under no obligation to update or otherwise correct this information. Advanced Micro Devices, Inc. makes no representations or warranties with respect to the accuracy or completeness of the contents of this document, and assumes no liability of any kind, including the implied warranties of noninfringement, merchantability or fitness for particular purposes, with respect to the operation oruse of AMD hardware, software or other products described herein. No license, including implied or arising by estoppel, to any intellectual property rights is granted by this document. Terms and limitations applicable to the purchase or use of AMD’s products are as set forth in a signed agreement between the parties or in AMD's Standard Terms and Conditions of Sale.TrademarksAMD, the AMD Arrow logo, and combinations thereof are trademarks of Advanced Micro Devices, Inc.Dolby is a trademark of Dolby Laboratories.ENERGY STAR is a registered trademark of the U.S. Environmental Protection Agency.HDMI is a trademark of HDMI Licensing, LLC.HyperTransport is a licensed trademark of the HyperTransport Technology Consortium.Microsoft, Windows, Windows Vista, and DirectX are registered trademarks of Microsoft Corporation.MMX is a trademark of Intel Corporation.OpenCL is a trademark of Apple Inc. used by permission by Khronos.PCIe is a registered trademark of PCI-Special Interest Group (PCI-SIG).Other product names used in this publication are for identification purposes only and may be trademarks of their respective companies.Dolby Laboratories, Inc.Manufactured under license from Dolby Laboratories.Rovi CorporationThis device is protected by U.S. patents and other intellectual property rights. The use of Rovi Corporation's copy protection technology in the device must be authorized by Rovi Corporation and is intended for home and other limited pay-per-view uses only, unless otherwise authorized in writing by Rovi Corporation.Reverse engineering or disassembly is prohibited.USE OF THIS PRODUCT IN ANY MANNER THA T COMPLIES WITH THE MPEG-2 STANDARD IS EXPRESSLY PROHIBITED WITHOUT A LICENSE UNDER APPLICABLE PATENTS IN THE MPEG-2 PA TENT PORTFOLIO, WHICH LICENSE IS A V AILABLE FROM MPEG LA, L.L.C., 6312 S. FIDDLERS GREEN CIRCLE, SUITE 400E, GREENWOOD VILLAGE, COLORADO 80111.Contents3ZenDNN User Guide 57300Rev. 4.0January 2023ContentsRevision History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5Chapter 1Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6Chapter 2Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7Chapter 3Release Highlights . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8Chapter 4Supported OS and Compilers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94.1OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94.2Compilers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9Chapter 5Runtime Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10Chapter 6Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11Chapter 7License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13Chapter 8Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144List of Tables 57300Rev. 4.0January 2023ZenDNN User Guide List of TablesTable 1.Log Actors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11Revision History5ZenDNN User Guide 57300Rev. 4.0January 2023Revision History DateRevision Description January 20234.0Updated supported TensorFlow, ONNX Runtime, and PyTorch versions.June 2022 3.3•Updated supported TensorFlow and PyTorch versions.•Removed Chapter 5 Prerequisites and Chapter 6 AOCC and AOCL (AMD-BLIS) Library Installation.December 2021 3.2Updated supported TensorFlow, ONNX Runtime, and PyTorch versions.August 2021 3.1Updated supported TensorFlow versions.April 2021 3.0Initial version.6Introduction Chapter 157300Rev. 4.0January 2023ZenDNN User Guide Chapter 1IntroductionZenDNN (Zen Deep Neural Network) Library accelerates deep learning inference applications on AMD CPUs. This library, which includes APIs for basic neural network building blocks optimized for AMD CPUs, targets deep learning application and framework developers with the goal of improving inference performance on AMD CPUs across a variety of workloads, including computer vision, natural language processing (NLP), and recommender systems. ZenDNN leverages oneDNN/DNNL v2.6.3's basic infrastructure and APIs. ZenDNN optimizes several APIs and adds new APIs, which are currently integrated into TensorFlow, ONNX Runtime, and PyTorch. ZenDNN depends on:•BLAS-like Library Instantiation Software (AOCL-BLIS) library for its BLAS (Basic Linear Algebra Subprograms) API needs •AMD Math Library (LibM) for Core Math needs •Composable Kernel for convolutions using an implicit GEMM algorithmAOCL-BLIS and AOCL-LibM are required dependencies for ZenDNN, whereas AMD Composable Kernel is an optional dependency.Chapter 2Scope7ZenDNN User Guide 57300Rev. 4.0January 2023Chapter 2ScopeThe scope of ZenDNN is to support AMD EPYC TM CPUs on the Linux ® platform. ZenDNN v4.0 offers optimized primitives, such as Convolution, MatMul, Elementwise, and Pool (Max and Average) that improve performance of many convolutional neural networks, recurrent neural networks, transformer-based models, and recommender system models. For the primitives not supported by ZenDNN, execution will fall back to the native path of the framework.8Release Highlights Chapter 357300Rev. 4.0January 2023ZenDNN User Guide Chapter 3Release Highlights Following are the highlights of this release:•ZenDNN library is integrated with TensorFlow v2.10, ONNX Runtime v1.12.1, and PyTorch v1.12.•Python v3.7-v3.10 have been used to generate the following wheel files (*.whl):–TensorFlow v2.10–PyTorch v1.12–ONNX Runtime v1.12.1•Added the following environment variables for tuning performance:–Memory Pooling (Persistent Memory Caching):–ZENDNN_ENABLE_MEMPOOL for all the TensorFlow models–Added MEMPOOL support for INT8 models–Convolution Operation:–ZENDNN_CONV_ALGO for all the TensorFlow models–Added new ALGO paths–Matrix Multiplication Operation:–ZENDNN_GEMM_ALGO for all the models–Added new ALGO paths and experimental version of auto-tuner•NHWC (default format) and Blocked Format (NCHWc8) continue to be supported.ZenDNN library is intended to be used in conjunction with the frameworks mentioned above and cannot be used independently. It is inherited from oneDNN v2.6.3.The latest information on the ZenDNN release and installers is available on AMD Developer Central (https:///en/developer/zendnn.html ).Chapter 4Supported OS and Compilers9ZenDNN User Guide 57300Rev. 4.0January 2023Chapter 4Supported OS and Compilers This release of ZenDNN supports the following Operating Systems (OS) and compilers:4.1OS •Ubuntu ® 20.04 LTS and later •Red Hat ® Enterprise Linux ® (RHEL) 9.0 and later •CentOS Stream 9 and later4.2CompilersGCC 9.3 and later10Runtime Dependencies Chapter 557300Rev. 4.0January 2023ZenDNN User Guide Chapter 5Runtime Dependencies ZenDNN has the following runtime dependencies:•GNU C library (glibc.so )•GNU Standard C++ library (libstdc++.so )•Dynamic linking library (libdl.so )•POSIX Thread library (libpthread.so )•C Math Library (libm.so )•OpenMP (libomp.so )•Python v3.7-v3.10 for:–TensorFlow v2.10–ONNX Runtime v1.12.1–PyTorch v1.12Since ZenDNN is configured to use OpenMP, a C++ compiler with OpenMP 2.0 or later is required for runtime execution.Chapter 6Logs 11Chapter 6LogsLogging is disabled in the ZenDNN library by default. It can be enabled using the environment variable ZENDNN_LOG_OPTS before running any tests. Logging behavior can be specified by setting the environment variable ZENDNN_LOG_OPTS to a comma-delimited list of ACTOR:DBGLVL pairs.The different ACTORS are as follows:For example:•To turn on info logging, use ZENDNN_LOG_OPTS=ALL:2•To turn off all logging, use ZENDNN_LOG_OPTS=ALL:-1•To only log errors, use ZENDNN_LOG_OPTS=ALL:0•To only log info for ALGO, use ZENDNN_LOG_OPTS=ALL:-1,ALGO:2•To only log info for CORE, use ZENDNN_LOG_OPTS=ALL:-1,CORE:2•To only log info for API, use ZENDNN_LOG_OPTS=ALL:-1,API:2•To only log info for PROF (profile), use ZENDNN_LOG_OPTS=ALL:-1,PROF:2•To only log info for FWK, use ZENDNN_LOG_OPTS=ALL:-1,FWK:2Table 1.Log Actors ActorDescription ALGOL ogs all the executed algorithms.CORELogs all the core ZenDNN library operations.APIL ogs all the ZenDNN API calls.TESTLogs all the calls used in API tests, functionality tests, and regression tests.PROFLogs the performance of operations in millisecond.FWK Logs all the framework (Tensorflow, ONNX Runtime, and PyTorch) specific calls.The Different Debug Levels (DBGLVL) are as follows:enum LogLevel{LOG_LEVEL_DISABLED = -1,LOG_LEVEL_ERROR = 0,LOG_LEVEL_WARNING = 1,LOG_LEVEL_INFO = 2,LOG_LEVEL_VERBOSE0 = 3,LOG_LEVEL_VERBOSE1 = 4,LOG_LEVEL_VERBOSE2 = 5};12Logs Chapter 6Chapter 7LicenseZenDNN is licensed under Apache License Version 2.0. Refer to the “LICENSE” file for the full license text and copyright notice.This distribution includes third party software governed by separate license terms.3-clause BSD license:•Xbyak (https:///herumi/xbyak)•Googletest (https:///google/googletest)•Instrumentation and Tracing Technology API (https:///intel/ittapi)Apache License Version 2.0:•oneDNN (https:///oneapi-src/oneDNN)•Xbyak_aarch64 (https:///fujitsu/xbyak_aarch64)•TensorFlow (https:///tensorflow/tensorflow)Boost Software License, Version 1.0:Boost C++ Libraries (https:///)BSD/Apache/Software Licenses from PyTorch:PyTorch (https:///pytorch/pytorch)This third-party software, even if included with the distribution of the Advanced Micro Devices software, may be governed by separate license terms, including without limitation, third-party license terms, and open-source software license terms. These separate license terms govern use of the third-party programs as set forth in the THIRD-PARTY-PROGRAMS file.Chapter 7License13Chapter 8Technical SupportPlease email ********************* for questions, issues, and feedback on ZenDNN.14Technical Support Chapter 8。
api接口文档2篇API接口文档是指对某个API接口的详细说明和规范,可以帮助开发人员快速了解和使用该接口。
本文将介绍两篇关于API接口的文档,涉及接口的功能、请求参数、返回参数等内容。
以下是对两篇API 接口文档的详细描述。
第一篇API接口文档接口名称: 用户登录接口接口功能: 用户通过该接口进行登录操作,获取登录凭证请求URL: /api/login请求方法: POST请求参数:- username (string): 用户名,必填字段- password (string): 密码,必填字段返回参数:- code (int): 返回码,0表示成功,其他值表示失败- message (string): 返回结果信息- token (string): 登录凭证,用于后续请求的身份认证备注: 需要传递参数格式为JSON第二篇API接口文档接口名称: 商品列表接口接口功能: 获取商品列表,支持分页和筛选功能请求URL: /api/products请求方法: GET请求参数:- page (int): 当前页码,默认为1- size (int): 每页显示数量,默认为10- keyword (string): 关键词,模糊搜索商品名称- category (string): 商品分类,筛选商品分类返回参数:- code (int): 返回码,0表示成功,其他值表示失败- message (string): 返回结果信息- data (object): 返回的商品列表数据- id (int): 商品ID- name (string): 商品名称- price (float): 商品价格备注: 无需传递参数时,请求URL为/api/products,参数需要拼接在URL后面,如/api/products?page=2&size=20通过以上对两篇API接口文档的介绍,开发人员可以清楚地了解接口的功能、请求方法、请求参数和返回参数等详细信息。
1111
Zendesk API 是一种用于与 Zendesk 平台进行交互的接口。
它允许开发人员使用编程语言来访问和操作 Zendesk 中的数据,例如创建、读取、更新和删除 tickets、users、organizations 等。
以下是使用 Zendesk API 的一般步骤:
1. 注册 Zendesk API 账户:首先,你需要在 Zendesk 开发者门户上注册一个 API 账户。
2. 获取 API 密钥:在注册 API 账户后,你将获得一个 API 密钥。
这个密钥将用于进行身份验证。
3. 选择 API 端点:Zendesk API 提供了许多不同的端点,用于访问不同的 Zendesk 数据。
你需要选择你要使用的 API 端点。
4. 发送 API 请求:使用你选择的编程语言,发送 HTTP 请求到 API 端点。
请求中应包含你的 API 密钥以及其他必要的参数。
5. 处理 API 响应:API 将会返回一个响应,你需要处理这个响应以获取你需要的数据。
6. 错误处理:如果 API 请求失败,你需要处理错误情况。
需要注意的是,Zendesk API 有不同的版本,每个版本都有不同的功能和限制。
你需要选择适合你需求的版本,并按照相应的文档进行开发。
另外,Zendesk API 也提供了一些客户端库,例如 Python 的 zendesk.py、JavaScript 的 ZendeskSDK 等,这些库可以简化 API 的使用。
希望这个回答对你有所帮助。
如果你需要更详细的信息,请参考 Zendesk API 文档。
为了创建项目,你必须首先下载并解压缩Zend框架。
相处了一个完整的Zend框架的PHP堆栈最简单的方法是通过安装»Zend服务器。
Zend服务器有本地安装的Mac OSX,Windows中的Fedora Core和Ubuntu,以及作为一个普遍的兼容大多数Linux发行版的安装包。
框架文件后,您已经安装了Zend服务器,可根据发现的/ usr /本地/ ZEND / Mac OSX和Linux上的份额/ ZendFramework,和C :\ Program Files文件\的Zend \ ZendServer \共享\ ZendFramework Windows上。
已配置的include_path将包括Zend框架。
或者,您可以»下载最新版本的Zend框架和提取的内容,使你这样做了说明。
或者,您可以将路径添加到库/归档文件的子目录到你的php.ini 的设置。
这就是它!Zend框架正在安装,并准备使用。
注:ZF在您的Zend Framework安装的命令行工具是一个bin /子目录中,包含脚本zf.sh和zf.bat,分别为基于UNIX和基于Windows的用户。
使这个脚本的绝对路径的说明。
无论你看到的命令引用ZF,请替换脚本的绝对路径。
在类Unix系统,你可能想使用shell 的别名功能:如果你有问题设立的ZF命令行工具,请参阅到的别名zf.sh =路径/ / ZendFramework / BIN / zf.sh。
手册。
打开一个终端(在Windows中,开始- >运行,然后使用CMD)。
导航到一个目录,您想启动一个项目。
然后,使用相应的脚本路径,并执行下列之一:1.%ZF创建项目快速启动运行此命令将创建您的网站的基本结构,包括你最初的控制器和视图。
树看起来如下:1.快速入门2.| - 应用3.| | - Bootstrap.php4.| | - CONFIGS5.| |` - 的application.ini6.| | - 控制器7.| | | - ErrorController.php8.| |` - IndexController.php9.| | - 模型10.|` - 意见11.| | - 佣工12.|` - 脚本13.| | - 错误14.| |` - error.phtml15.|` - 指数16.|` - index.phtml17.| - 库18.| - 公共19.| | - htaccess的。
Zend API:深入 PHP 内核 (-)译序及进度目录(已翻译完毕)译序:网上关于 PHP 的资料多如牛毛,关于其核心 Zend Engine 的却少之又少。
PHP 中文手册出现已 N 年,但 Zend API 的翻译却仍然不见动静,小弟自觉对 Zend Engine 略有小窥,并且翻译也有助于强迫自己对文章的进一步理解,于是尝试翻译此章,英文不好,恭请方家指点校核。
转载请注明来自抚琴居(译者主页):/PHP 中文手册《Zend API:深入 PHP 内核》一章当前翻译进度(已翻译完毕):1.摘要2.概述3.可扩展性4.源码布局5.自动构建系统6.开始创建扩展7.使用扩展8.故障处理9.关于模块代码的讨论10.接收参数11.创建变量12.使用拷贝构造函数复制变量内容13.返回函数值14.信息输出15.启动函数与关闭函数16.调用用户函数17.支持初始化文件(php.ini)18.何去何从19.参考:关于配置文件的一些宏20.API 宏Zend API:深入 PHP 内核 (二)摘要摘要知者不言,言者不知。
――老子《道德经》五十六章有时候,单纯依靠 PHP “本身”是不行的。
尽管普通用户很少遇到这种情况,但一些专业性的应用则经常需要将 PHP 的性能发挥到极致(这里的性能是指速度或功能)。
由于受到 PHP 语言本身的限制,同时还可能不得不把庞大的库文件包含到每个脚本当中。
因此,某些新功能并不是总能被顺利实现,所以我们必须另外寻找一些方法来克服 PHP 的这些缺点。
了解到了这一点,我们就应该接触一下 PHP 的心脏并探究一下它的内核-可以编译成 PHP 并让之工作的 C 代码-的时候了。
Zend API:深入 PHP 内核 (三)概述“扩展 PHP”说起来容易做起来难。
PHP 现在已经发展成了一个具有数兆字节源代码的非常成熟的系统。
要想深入这样的一个系统,有很多东西需要学习和考虑。
在写这一章节的时候,我们最终决定采用“边学边做”的方式。
这也许并不是最科学和专业的方式,但却应该是最有趣和最有效的一种方式。
在下面的小节里,你首先会非常快速的学习到如何写一个虽然很基础但却能立即运行的扩展,然后将会学习到有关 Zend API 的高级功能。
另外一个选择就是将其作为一个整体,一次性的讲述所有的这些操作、设计、技巧和诀窍等,并且可以让我们在实际动手前就可以得到一副完整的愿景。
这看起来似乎是一个更好的方法,也没有死角,但它却枯燥无味、费时费力,很容易让人感到气馁。
这就是我们为什么要采用非常直接的讲法的原因。
注意,尽管这一章会尽可能多讲述一些关于 PHP 内部工作机制的知识,但要想真的给出一份在任何时间任何情况下的PHP 扩展指南,那简直是不可能的。
PHP 是如此庞大和复杂,以致于只有你亲自动手实践一下才有可能真正理解它的内部工作机制,因此我们强烈推荐你随时参考它的源代码来进行工作。
Zend 是什么? PHP 又是什么?Zend 指的是语言引擎,PHP 指的是我们从外面看到的一套完整的系统。
这听起来有点糊涂,但其实并不复杂(见图3-1 PHP 内部结构图)。
为了实现一个 WEB 脚本的解释器,你需要完成以下三个部分的工作:1.解释器部分:负责对输入代码的分析、翻译和执行;2.功能性部分:负责具体实现语言的各种功能(比如它的函数等等);3.接口部分:负责同 WEB 服务器的会话等功能。
Zend 包括了第一部分的全部和第二部分的局部,PHP 包括了第二部分的局部和第三部分的全部。
他们合起来称之为PHP 包。
Zend 构成了语言的核心,同时也包含了一些最基本的 PHP 预定义函数的实现。
PHP 则包含了所有创造出语言本身各种显著特性的模块。
图3-1 PHP 内部结构图下面将要讨论PHP 允许在哪里扩展以及如何扩展。
Zend API:深入 PHP 内核 (四)可扩展性正如上图(图3-1 PHP 内部结构图)所示,PHP 主要以三种方式来进行扩展:外部模块,内建模块和 Zend 引擎。
下面我们将分别讨论这些方式:外部模块外部模块可以在脚本运行时使用 dl() 函数载入。
这个函数从磁盘载入一个共享对象并将它的功能与调用该函数的脚本进行绑定并使之生效。
脚本终止后,这个外部模块将在内存中被丢弃。
这种方式有利有弊,如下表所示:优点缺点外部模块不需要重新对 PHP 进共享对象在每次脚本调用时都需要对其进行加载,速度较慢。
行编译。
PHP通过“外包”方式来让自身的附加的外部模块文件会让磁盘变得比较散乱。
体积保持很小。
每个想使用该模块功能的脚本都必须使用dl() 函数手动加载,或者在 php.ini 文件当中添加一些扩展标签(这并不总是一个恰当的解决方案)。
综上所述,外部模块非常适合开发第三方产品,较少使用的附加的小功能或者仅仅是调试等这些用途。
为了迅速开发一些附加功能,外部模块是最佳方式。
但对于一些经常使用的、实现较大的,代码较为复杂的应用,那就有些得不偿失了。
第三方可能会考虑在 php.ini 文件中使用扩展标签来创建一个新的外部模块。
这些外部模块完全同主PHP 包分离,这一点非常适合应用于一些商业环境。
商业性的发行商可以仅发送这些外部模块而不必再额外创建那些并不允许绑定这些商业模块的PHP 二进制代码。
内建模块内建模块被直接编译进 PHP 并存在于每一个 PHP 处理请求当中。
它们的功能在脚本开始运行时立即生效。
和外部模块一样,内建模块也有一下利弊:优点缺点无需专门手动载入,功能即时生效。
修改内建模块时需要重新编译PHP。
无需额外的磁盘文件,所有功能均内置在 PHP 二PHP 二进制文件会变大并且会消耗更多的内存。
进制代码当中。
Zend 引擎当然,你也能直接在 Zend 引擎里面进行扩展。
如果你需要在语言特性方面做些改动或者是需要在语言核心内置一些特别的功能,那么这就是一种很好的方式。
但一般情况下应该尽力避免对 Zend 引擎的修改。
这里面的改动会导致和其他代码的不兼容,而且几乎没有人会适应打过特殊补丁的 Zend 引擎。
况且这些改动与主 PHP 源代码是不可分割的,因此就有可能在下一次的官方的源代码更新中被覆盖掉。
因此,这种方式通常被认为是“不良的习惯”。
由于使用极其稀少,本章将不再对此进行赘述。
Zend API:深入 PHP 内核 (五)源码布局在我们开始讨论具体编码这个话题前,你应该让自己熟悉一下 PHP 的源代码树以便可以迅速地对各个源文件进行定位。
这也是编写和调试 PHP 扩展所必须具备的一种能力。
下表列出了一些主要目录的内容:目录内容php-src 包含了PHP主源文件和主头文件;在这里你可以找到所有的 PHP API 定义、宏等内容。
(重要). 其他的一些东西你也可以在这里找到。
php-src/ext 这里是存放动态和内建模块的仓库;默认情况下,这些就是被集成于主源码树中的“官方” PHP 模块。
自 PHP 4.0开始,这些PHP标准扩展都可以编译为动态可载入的模块。
(至少这些是可以的)。
php-src/main 这个目录包含主要的 PHP 宏和定义。
(重要)php-src/pear 这个目录就是“PHP 扩展与应用仓库”的目录。
包含了PEAR 的核心文件。
php-src/sapi 包含了不同服务器抽象层的代码。
TSRM Zend 和 PHP的“线程安全资源管理器” (TSRM) 目录。
ZendEngine2 包含了Zend 引擎文件;在这里你可以找到所有的 Zend API 定义与宏等。
(重要) 当然,讨论 PHP 包里面全部每一个文件无疑是超出了本章的范围,但你还是应该仔细看一下下面的几个文件•php-src/main/php.h, 位于PHP 主目录。
这个文件包含了绝大部分 PHP 宏及 API 定义。
•php-src/Zend/zend.h, 位于 Zend 主目录。
这个文件包含了绝大部分 Zend 宏及 API 定义。
•php-src/Zend/zend_API.h, 也位于 Zend 主目录,包含了Zend API 的定义。
除此之外,你也应该注意一下这些文件所包含的一些文件。
举例来说,哪些文件与 Zend 执行器有关,哪些文件又为PHP 初始化工作提供了支持等等。
在阅读完这些文件之后,你还可以花点时间再围绕PHP包来看一些文件,了解一下这些文件和模块之间的依赖性――它们之间是如何依赖于别的文件又是如何为其他文件提供支持的。
同时这也可以帮助你适应一下 PHP 创作者们代码的风格。
要想扩展 PHP,你应该尽快适应这种风格。
扩展规范Zend 是用一些特定的规范构建的。
为了避免破坏这些规范,你应该遵循以下的几个规则:宏几乎对于每一项重要的任务,Zend 都预先提供了极为方便的宏。
在下面章节的图表里将会描述到大部分基本函数、结构和宏。
这些宏定义大多可以在 Zend.h 和 Zend_API.h 中找到。
我们建议您在学习完本节之后仔细看一下这些文件。
(当然你也可以现在就阅读这些文件,但你可能不会留下太多的印象。
)内存管理资源管理仍然是一个极为关键的问题,尤其是对服务器软件而言。
资源里最具宝贵的则非内存莫属了,内存管理也必须极端小心。
内存管理在 Zend 中已经被部分抽象,而且你也应该坚持使用这些抽象,原因显而易见:由于得以抽象,Zend 就可以完全控制内存的分配。
Zend 可以确定一块内存是否在使用,也可以自动释放未使用和失去引用的内存块,因此就可以避免内存泄漏。
下表列出了一些常用函数:函数描述emalloc()用于替代malloc()。
efree()用于替代free()。
estrdup()用于替代strdup()。
estrndup()用于替代strndup()。
速度要快于estrdup()而且是二进制安全的。
如果你在复制之前预先知道这个字符串的长度那就推荐你使用这个函数。
ecalloc()用于替代calloc()。
erealloc()用于替代realloc()。
emalloc(), estrdup(), estrndup(), ecalloc(), 和 erealloc() 用于申请内部的内存,efree() 则用来释放这些前面这些函数申请的内存。
e*() 函数所用到的内存仅对当前本地的处理请求有效,并且会在脚本执行完毕,处理请求终止时被释放。
Zend 还有一个线程安全资源管理器,这可以为多线程WEB 服务器提供更好的本地支持。
不过这需要你为所有的全局变量申请一个局部结构来支持并发线程。
但是因为在写本章内容时Zend 的线程安全模式仍未完成,因此我们无法过多地涉及这个话题。
目录与文件函数下列目录与文件函数应该在 Zend 模块内使用。
它们的表现和对应的 C 语言版本完全一致,只是在线程级提供了虚拟目录的支持。